Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Herb-AI/HerbCore.jl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.2
Choose a base ref
...
head repository: Herb-AI/HerbCore.jl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.3.3
Choose a head ref
  • 8 commits
  • 6 files changed
  • 1 contributor

Commits on Nov 15, 2024

  1. Add pirated methods from HerbGrammar

    ReubenJ committed Nov 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ReubenJ Reuben Gardos Reid
    Copy the full SHA
    1bf674c View commit details

Commits on Nov 26, 2024

  1. Remove empty-child RuleNode and UniformHole constructors

    They are better-suited as functions in `HerbGrammar`
    ReubenJ committed Nov 26, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ReubenJ Reuben Gardos Reid
    Copy the full SHA
    f6cea02 View commit details
  2. Add tests

    ReubenJ committed Nov 26, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ReubenJ Reuben Gardos Reid
    Copy the full SHA
    e3a5874 View commit details
  3. Test grammar Base.show

    ReubenJ committed Nov 26, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ReubenJ Reuben Gardos Reid
    Copy the full SHA
    3b208c7 View commit details

Commits on Nov 27, 2024

  1. Remove test dependency on HerbGrammar

    ReubenJ committed Nov 27, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ReubenJ Reuben Gardos Reid
    Copy the full SHA
    e8e24ac View commit details
  2. Add Base.getindex test

    ReubenJ committed Nov 27, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ReubenJ Reuben Gardos Reid
    Copy the full SHA
    d8232aa View commit details
  3. Add Aqua, remove extraneous exports

    ReubenJ committed Nov 27, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ReubenJ Reuben Gardos Reid
    Copy the full SHA
    e3189be View commit details
  4. Merge pull request #31 from Herb-AI/feat/anti-piracy

    Address Aqua type piracy errors
    ReubenJ authored Nov 27, 2024
    2

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    52359a7 View commit details
Showing with 59 additions and 8 deletions.
  1. +5 −7 Project.toml
  2. +3 −1 src/HerbCore.jl
  3. +8 −0 src/grammar.jl
  4. +4 −0 src/rulenode.jl
  5. +4 −0 test/Project.toml
  6. +35 −0 test/runtests.jl
12 changes: 5 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name = "HerbCore"
uuid = "2b23ba43-8213-43cb-b5ea-38c12b45bd45"
authors = ["Jaap de Jong <jaapdejong15@gmail.com>", "Nicolae Filat <N.Filat@student.tudelft.nl>", "Tilman Hinnerichs <t.r.hinnerichs@tudelft.nl>", "Sebastijan Dumancic <s.dumancic@tudelft.nl>"]
version = "0.3.2"
version = "0.3.3"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

[compat]
AbstractTrees = "0.4.5"
julia = "^1.8"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
4 changes: 3 additions & 1 deletion src/HerbCore.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module HerbCore

using AbstractTrees

include("grammar.jl")
include("rulenode.jl")
include("constraint.jl")
include("grammar.jl")

export
AbstractRuleNode,
8 changes: 8 additions & 0 deletions src/grammar.jl
Original file line number Diff line number Diff line change
@@ -19,3 +19,11 @@ If the grammar is non-probabilistic, the list can be `nothing`.
For concrete types, see `ContextSensitiveGrammar` within the `HerbGrammar` module.
"""
abstract type AbstractGrammar end

function Base.show(io::IO, grammar::AbstractGrammar)
for i in eachindex(grammar.rules)
println(io, i, ": ", grammar.types[i], " = ", grammar.rules[i])
end
end

Base.getindex(grammar::AbstractGrammar, typ::Symbol) = grammar.bytype[typ]
4 changes: 4 additions & 0 deletions src/rulenode.jl
Original file line number Diff line number Diff line change
@@ -16,6 +16,10 @@ Expression trees consist of [`RuleNode`](@ref)s and [`AbstractHole`](@ref)s.
"""
abstract type AbstractRuleNode end

# Interface to AbstractTrees.jl
AbstractTrees.children(node::AbstractRuleNode) = get_children(node)
AbstractTrees.nodevalue(node::AbstractRuleNode) = get_rule(node)

"""
RuleNode <: AbstractRuleNode
4 changes: 4 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
35 changes: 35 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
using AbstractTrees: children, nodevalue, treeheight
using Aqua
using HerbCore
using Test

@testset "HerbCore.jl" verbose=true begin
@testset "Aqua Tests" Aqua.test_all(HerbCore)

@testset "AbstractTrees Interface" begin
@test nodevalue(RuleNode(1)) == 1
@test isempty(children(RuleNode(1)))
@test length(children(RuleNode(1, [RuleNode(2), RuleNode(2)]))) == 2
@test treeheight(RuleNode(1)) == 0
@test treeheight(RuleNode(1, [RuleNode(2), RuleNode(2)])) == 1
end

@testset "RuleNode tests" begin
@testset "Equality tests" begin
@test RuleNode(1) == RuleNode(1)
@@ -335,4 +347,27 @@ using Test
"12{14,2{4{hole[Bool[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]}},2{4{6}}}"
end
end

@testset "Grammar" begin
struct ExGrammar <: AbstractGrammar
rules::Vector{Any}
types::Vector{Symbol}
bytype::Dict{Symbol, Vector{Int}}
# ...
# only partially implementing the AbstractGrammar interface
# to test the Base.show
end

g = ExGrammar([1], [:A], Dict([:A => [1]]))

@testset "show" begin
io = IOBuffer()
Base.show(io, g)
@test String(take!(io)) == "1: A = 1\n"
end

@testset "get_index" begin
@test g[:A] == [1]
end
end
end