From d1cea2a9e3dde9d315d5df10b06dbb95a25ae7e2 Mon Sep 17 00:00:00 2001 From: Reuben Gardos Reid <5456207+ReubenJ@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:49:16 +0200 Subject: [PATCH 1/2] `FixedShapedHole` -> `UniformHole` --- src/HerbCore.jl | 2 +- src/rulenode.jl | 16 ++++++++-------- test/runtests.jl | 40 ++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/HerbCore.jl b/src/HerbCore.jl index 2f61d22..a2a53a0 100644 --- a/src/HerbCore.jl +++ b/src/HerbCore.jl @@ -8,7 +8,7 @@ export AbstractRuleNode, RuleNode, Hole, - FixedShapedHole, + UniformHole, VariableShapedHole, HoleReference, diff --git a/src/rulenode.jl b/src/rulenode.jl index 968e7d3..b0f1a8d 100644 --- a/src/rulenode.jl +++ b/src/rulenode.jl @@ -48,12 +48,12 @@ The `domain` is a bitvector, where the `i`th bit is set to true if the `i`th rul abstract type Hole <: AbstractRuleNode end """ - FixedShapedHole <: Hole + UniformHole <: Hole - `domain`: A bitvector, where the `i`th bit is set to true if the `i`th rule in the grammar can be applied. All rules in the domain are required to have the same childtypes. - `children`: The children of this hole in the expression tree. """ -mutable struct FixedShapedHole <: Hole +mutable struct UniformHole <: Hole domain::BitVector children::Vector{AbstractRuleNode} end @@ -118,7 +118,7 @@ Base.:(==)(A::Hole, B::Hole) = false Base.copy(r::RuleNode) = RuleNode(r.ind, r._val, r.children) Base.copy(h::VariableShapedHole) = VariableShapedHole(copy(h.domain)) -Base.copy(h::FixedShapedHole) = FixedShapedHole(copy(h.domain), h.children) +Base.copy(h::UniformHole) = UniformHole(copy(h.domain), h.children) function Base.hash(node::RuleNode, h::UInt=zero(UInt)) retval = hash(node.ind, h) @@ -152,7 +152,7 @@ function Base.show(io::IO, node::Hole; separator=",", last_child::Bool=false) end end -function Base.show(io::IO, node::FixedShapedHole; separator=",", last_child::Bool=false) +function Base.show(io::IO, node::UniformHole; separator=",", last_child::Bool=false) print(io, "fshole[$(node.domain)]") if !isempty(node.children) print(io, "{") @@ -413,7 +413,7 @@ end Recursively counts the number of holes in an [`AbstractRuleNode`](@ref) """ number_of_holes(rn::RuleNode) = reduce(+, [number_of_holes(c) for c ∈ rn.children], init=0) -number_of_holes(rn::FixedShapedHole) = 1 + reduce(+, [number_of_holes(c) for c ∈ rn.children], init=0) +number_of_holes(rn::UniformHole) = 1 + reduce(+, [number_of_holes(c) for c ∈ rn.children], init=0) number_of_holes(rn::VariableShapedHole) = 1 @@ -445,7 +445,7 @@ Returns the children of the given [`AbstractRuleNode`](@ref) """ get_children(rn::AbstractRuleNode)::Vector{AbstractRuleNode} = rn.children get_children(::VariableShapedHole)::Vector{AbstractRuleNode} = NOCHILDREN -get_children(h::FixedShapedHole)::Vector{AbstractRuleNode} = h.children +get_children(h::UniformHole)::Vector{AbstractRuleNode} = h.children """ @@ -455,7 +455,7 @@ Returns true iff the children of the [`AbstractRuleNode`](@ref) are known. """ isfixedshaped(::RuleNode)::Bool = true isfixedshaped(::VariableShapedHole)::Bool = false -isfixedshaped(::FixedShapedHole)::Bool = true +isfixedshaped(::UniformHole)::Bool = true """ @@ -465,7 +465,7 @@ Returns whether the [`AbstractRuleNode`] holds a single rule. This is always the Holes are considered to be "filled" iff their domain size is exactly 1. """ isfilled(rn::RuleNode)::Bool = true -isfilled(hole::FixedShapedHole)::Bool = (sum(hole.domain) == 1) +isfilled(hole::UniformHole)::Bool = (sum(hole.domain) == 1) isfilled(hole::VariableShapedHole)::Bool = (sum(hole.domain) == 1) diff --git a/test/runtests.jl b/test/runtests.jl index d8102ec..44a0872 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -98,8 +98,8 @@ using Test end @testset "get_node_at_location" begin - rulenode = FixedShapedHole(BitVector((1, 1, 0, 0)), [RuleNode(3), RuleNode(4)]) - @test get_node_at_location(rulenode, Vector{Int64}()) isa FixedShapedHole + rulenode = UniformHole(BitVector((1, 1, 0, 0)), [RuleNode(3), RuleNode(4)]) + @test get_node_at_location(rulenode, Vector{Int64}()) isa UniformHole @test get_node_at_location(rulenode, [1]).ind == 3 @test get_node_at_location(rulenode, [2]).ind == 4 end @@ -107,7 +107,7 @@ using Test @testset "get_node_path" begin n1 = RuleNode(1) n2 = RuleNode(2) - n3 = FixedShapedHole(BitVector((1, 1, 1)), [RuleNode(1), n2]) + n3 = UniformHole(BitVector((1, 1, 1)), [RuleNode(1), n2]) n4 = RuleNode(1) root = RuleNode(4, [ RuleNode(4, [ @@ -124,30 +124,30 @@ using Test @testset "Length tests with holes" begin domain=BitVector((1, 1)) - @test length(FixedShapedHole(domain, [])) == 1 - @test length(FixedShapedHole(domain, [RuleNode(2)])) == 2 + @test length(UniformHole(domain, [])) == 1 + @test length(UniformHole(domain, [RuleNode(2)])) == 2 @test length(RuleNode(1,[RuleNode(2, [Hole(domain), RuleNode(4)])])) == 4 - @test length(FixedShapedHole(domain,[RuleNode(2, [RuleNode(4), RuleNode(4)])])) == 4 + @test length(UniformHole(domain,[RuleNode(2, [RuleNode(4), RuleNode(4)])])) == 4 end @testset "Depth tests with holes" begin domain=BitVector((1, 1)) - @test depth(FixedShapedHole(domain, [])) == 1 - @test depth(FixedShapedHole(domain, [RuleNode(2)])) == 2 + @test depth(UniformHole(domain, [])) == 1 + @test depth(UniformHole(domain, [RuleNode(2)])) == 2 @test depth(RuleNode(1,[RuleNode(2, [Hole(domain), RuleNode(4)])])) == 3 - @test depth(FixedShapedHole(domain,[RuleNode(2, [RuleNode(4), RuleNode(4)])])) == 3 + @test depth(UniformHole(domain,[RuleNode(2, [RuleNode(4), RuleNode(4)])])) == 3 end @testset "number_of_holes" begin domain=BitVector((1, 1)) @test number_of_holes(RuleNode(1)) == 0 @test number_of_holes(VariableShapedHole(domain)) == 1 - @test number_of_holes(FixedShapedHole(domain, [RuleNode(1), RuleNode(1)])) == 1 - @test number_of_holes(FixedShapedHole(domain, [VariableShapedHole(domain), RuleNode(1)])) == 2 + @test number_of_holes(UniformHole(domain, [RuleNode(1), RuleNode(1)])) == 1 + @test number_of_holes(UniformHole(domain, [VariableShapedHole(domain), RuleNode(1)])) == 2 @test number_of_holes(RuleNode(2, [VariableShapedHole(domain), RuleNode(1)])) == 1 - @test number_of_holes(FixedShapedHole(domain, [ + @test number_of_holes(UniformHole(domain, [ VariableShapedHole(domain), - FixedShapedHole(domain, [VariableShapedHole(domain), RuleNode(1)]) + UniformHole(domain, [VariableShapedHole(domain), RuleNode(1)]) ])) == 4 end @@ -155,11 +155,11 @@ using Test domain=BitVector((1, 1)) @test isfixedshaped(RuleNode(1, [RuleNode(2)])) == true - @test isfixedshaped(FixedShapedHole(domain, [RuleNode(2)])) == true + @test isfixedshaped(UniformHole(domain, [RuleNode(2)])) == true @test isfixedshaped(RuleNode(1)) == true @test isfixedshaped(RuleNode(1, [])) == true - @test isfixedshaped(FixedShapedHole(domain, [])) == true + @test isfixedshaped(UniformHole(domain, [])) == true @test isfixedshaped(VariableShapedHole(domain)) == false end @@ -172,8 +172,8 @@ using Test @test isfilled(RuleNode(1, [VariableShapedHole(domain1)])) == true @test isfilled(RuleNode(1, [VariableShapedHole(domain2)])) == true - @test isfilled(FixedShapedHole(domain1, [VariableShapedHole(domain2)])) == true - @test isfilled(FixedShapedHole(domain2, [VariableShapedHole(domain2)])) == false + @test isfilled(UniformHole(domain1, [VariableShapedHole(domain2)])) == true + @test isfilled(UniformHole(domain2, [VariableShapedHole(domain2)])) == false @test isfilled(VariableShapedHole(domain1)) == true @test isfilled(VariableShapedHole(domain2)) == false @@ -183,7 +183,7 @@ using Test domain_of_size_1=BitVector((0, 1, 0, 0, 0)) @test get_rule(RuleNode(99, [RuleNode(3), RuleNode(4)])) == 99 @test get_rule(RuleNode(2, [RuleNode(3), RuleNode(4)])) == 2 - @test get_rule(FixedShapedHole(domain_of_size_1, [RuleNode(5), RuleNode(6)])) == 2 + @test get_rule(UniformHole(domain_of_size_1, [RuleNode(5), RuleNode(6)])) == 2 @test get_rule(VariableShapedHole(domain_of_size_1)) == 2 end @@ -221,8 +221,8 @@ using Test @testset "hasdynamicvalue" begin @test hasdynamicvalue(RuleNode(1, "DynamicValue")) == true @test hasdynamicvalue(RuleNode(1)) == false - @test hasdynamicvalue(FixedShapedHole(BitVector((1, 0)), [RuleNode(1, "DynamicValue")])) == false - @test hasdynamicvalue(FixedShapedHole(BitVector((1, 0)), [RuleNode(1)])) == false + @test hasdynamicvalue(UniformHole(BitVector((1, 0)), [RuleNode(1, "DynamicValue")])) == false + @test hasdynamicvalue(UniformHole(BitVector((1, 0)), [RuleNode(1)])) == false @test hasdynamicvalue(VariableShapedHole(BitVector((1, 0)))) == false end end From bb9431913f3f818164ae47e32aba631a8251535e Mon Sep 17 00:00:00 2001 From: Reuben Gardos Reid <5456207+ReubenJ@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:05:20 +0200 Subject: [PATCH 2/2] `Hole` -> `AbstractHole` + `VariableShapedHole` -> `Hole` --- src/HerbCore.jl | 4 +-- src/rulenode.jl | 73 +++++++++++++++++++++++------------------------- test/runtests.jl | 36 ++++++++++++------------ 3 files changed, 55 insertions(+), 58 deletions(-) diff --git a/src/HerbCore.jl b/src/HerbCore.jl index a2a53a0..454ef33 100644 --- a/src/HerbCore.jl +++ b/src/HerbCore.jl @@ -7,9 +7,9 @@ include("grammar.jl") export AbstractRuleNode, RuleNode, - Hole, + AbstractHole, UniformHole, - VariableShapedHole, + Hole, HoleReference, depth, diff --git a/src/rulenode.jl b/src/rulenode.jl index b0f1a8d..065b0d8 100644 --- a/src/rulenode.jl +++ b/src/rulenode.jl @@ -9,10 +9,10 @@ An `AbstractRuleNode` is expected to implement the following functions: - `get_rule(::AbstractRuleNode)::Int`. Returns the index of the grammar rule it represents. - `get_children(::AbstractRuleNode)::Vector{AbstractRuleNode}`. Returns the children of this node. -Expression trees consist of [`RuleNode`](@ref)s and [`Hole`](@ref)s. +Expression trees consist of [`RuleNode`](@ref)s and [`AbstractHole`](@ref)s. - A [`RuleNode`](@ref) represents a certain production rule in the [`AbstractGrammar`](@ref). -- A [`Hole`](@ref) is a placeholder where certain rules in the grammar still can be applied. +- A [`AbstractHole`](@ref) is a placeholder where certain rules in the grammar still can be applied. """ abstract type AbstractRuleNode end @@ -39,46 +39,43 @@ end """ - Hole <: AbstractRuleNode + AbstractHole <: AbstractRuleNode -A [`Hole`](@ref) is a placeholder where certain rules from the grammar can still be applied. -The `domain` of a [`Hole`](@ref) defines which rules can be applied. +A [`AbstractHole`](@ref) is a placeholder where certain rules from the grammar can still be applied. +The `domain` of a [`AbstractHole`](@ref) defines which rules can be applied. The `domain` is a bitvector, where the `i`th bit is set to true if the `i`th rule in the grammar can be applied. """ -abstract type Hole <: AbstractRuleNode end +abstract type AbstractHole <: AbstractRuleNode end """ - UniformHole <: Hole + UniformHole <: AbstractHole - `domain`: A bitvector, where the `i`th bit is set to true if the `i`th rule in the grammar can be applied. All rules in the domain are required to have the same childtypes. - `children`: The children of this hole in the expression tree. """ -mutable struct UniformHole <: Hole +mutable struct UniformHole <: AbstractHole domain::BitVector children::Vector{AbstractRuleNode} end """ -VariableShapedHole <: Hole +Hole <: AbstractHole - `domain`: A bitvector, where the `i`th bit is set to true if the `i`th rule in the grammar can be applied. """ -mutable struct VariableShapedHole <: Hole +mutable struct Hole <: AbstractHole domain::BitVector end -Hole(domain::BitVector) = VariableShapedHole(domain) - - """ HoleReference Contains a hole and the path to the hole from the root of the tree. """ struct HoleReference - hole::Hole + hole::AbstractHole path::Vector{Int} end @@ -100,24 +97,24 @@ Create a [`RuleNode`](@ref) for the [`AbstractGrammar`](@ref) rule with index `i !!! warning Only use this constructor if you are absolutely certain that a rule is terminal and cannot have children. Use [`RuleNode(ind::Int, grammar::AbstractGrammar)`] for rules that might have children. - In general, [`Hole`](@ref)s should be used as a placeholder when the children of a node are not yet known. + In general, [`AbstractHole`](@ref)s should be used as a placeholder when the children of a node are not yet known. !!! compat Evaluate immediately functionality is not yet supported by most of Herb.jl. """ RuleNode(ind::Int, _val::Any) = RuleNode(ind, _val, AbstractRuleNode[]) -Base.:(==)(::RuleNode, ::Hole) = false -Base.:(==)(::Hole, ::RuleNode) = false +Base.:(==)(::RuleNode, ::AbstractHole) = false +Base.:(==)(::AbstractHole, ::RuleNode) = false Base.:(==)(A::RuleNode, B::RuleNode) = (A.ind == B.ind) && length(A.children) == length(B.children) && #required because zip doesn't check lengths all(isequal(a, b) for (a, b) ∈ zip(A.children, B.children)) # We do not know how the holes will be expanded yet, so we cannot assume equality even if the domains are equal. -Base.:(==)(A::Hole, B::Hole) = false +Base.:(==)(A::AbstractHole, B::AbstractHole) = false Base.copy(r::RuleNode) = RuleNode(r.ind, r._val, r.children) -Base.copy(h::VariableShapedHole) = VariableShapedHole(copy(h.domain)) +Base.copy(h::Hole) = Hole(copy(h.domain)) Base.copy(h::UniformHole) = UniformHole(copy(h.domain), h.children) function Base.hash(node::RuleNode, h::UInt=zero(UInt)) @@ -128,7 +125,7 @@ function Base.hash(node::RuleNode, h::UInt=zero(UInt)) return retval end -function Base.hash(node::Hole, h::UInt=zero(UInt)) +function Base.hash(node::AbstractHole, h::UInt=zero(UInt)) return hash(node.domain, h) end @@ -145,7 +142,7 @@ function Base.show(io::IO, node::RuleNode; separator=",", last_child::Bool=false end end -function Base.show(io::IO, node::Hole; separator=",", last_child::Bool=false) +function Base.show(io::IO, node::AbstractHole; separator=",", last_child::Bool=false) print(io, "hole[$(node.domain)]") if !last_child print(io, separator) @@ -177,7 +174,7 @@ function Base.length(root::AbstractRuleNode) end return retval end -Base.length(::VariableShapedHole) = 1 +Base.length(::Hole) = 1 """ Base.isless(rn₁::AbstractRuleNode, rn₂::AbstractRuleNode)::Bool @@ -224,7 +221,7 @@ function depth(root::AbstractRuleNode)::Int return retval end -depth(::VariableShapedHole) = 1 +depth(::Hole) = 1 """ @@ -238,7 +235,7 @@ Depth is `1` when `root == node`. """ function node_depth(root::AbstractRuleNode, node::AbstractRuleNode)::Int root ≡ node && return 1 - root isa VariableShapedHole && return 1 + root isa Hole && return 1 for c in root.children d = node_depth(c, node) d > 0 && (return d+1) @@ -323,7 +320,7 @@ function get_rulesequence(node::RuleNode, path::Vector{Int}) end end -get_rulesequence(::Hole, ::Vector{Int}) = Vector{Int}() +get_rulesequence(::AbstractHole, ::Vector{Int}) = Vector{Int}() """ rulesonleft(expr::RuleNode, path::Vector{Int})::Set{Int} @@ -359,7 +356,7 @@ function rulesonleft(expr::RuleNode, path::Vector{Int}) end end -rulesonleft(h::Hole, loc::Vector{Int}) = Set{Int}(findall(h.domain)) +rulesonleft(h::AbstractHole, loc::Vector{Int}) = Set{Int}(findall(h.domain)) """ @@ -376,11 +373,11 @@ function get_node_at_location(root::AbstractRuleNode, location::Vector{Int}) end """ - get_node_at_location(root::VariableShapedHole, location::Vector{Int}) + get_node_at_location(root::Hole, location::Vector{Int}) Retrieves the current hole, if location is this very hole. Throws error otherwise. """ -function get_node_at_location(root::VariableShapedHole, location::Vector{Int}) +function get_node_at_location(root::Hole, location::Vector{Int}) if location == [] return root end @@ -414,24 +411,24 @@ Recursively counts the number of holes in an [`AbstractRuleNode`](@ref) """ number_of_holes(rn::RuleNode) = reduce(+, [number_of_holes(c) for c ∈ rn.children], init=0) number_of_holes(rn::UniformHole) = 1 + reduce(+, [number_of_holes(c) for c ∈ rn.children], init=0) -number_of_holes(rn::VariableShapedHole) = 1 +number_of_holes(rn::Hole) = 1 """ contains_hole(rn::RuleNode) = any(contains_hole(c) for c ∈ rn.children) -Checks if an [`AbstractRuleNode`](@ref) tree contains a [`Hole`](@ref). +Checks if an [`AbstractRuleNode`](@ref) tree contains a [`AbstractHole`](@ref). """ contains_hole(rn::RuleNode) = any(contains_hole(c) for c ∈ rn.children) -contains_hole(hole::Hole) = true +contains_hole(hole::AbstractHole) = true """ contains_variable_shaped_hole(rn::RuleNode) -Checks if an [`AbstractRuleNode`](@ref) tree contains a [`VariableShapedHole`](@ref). +Checks if an [`AbstractRuleNode`](@ref) tree contains a [`Hole`](@ref). """ contains_variable_shaped_hole(rn::AbstractRuleNode) = any(contains_variable_shaped_hole(c) for c ∈ rn.children) -contains_variable_shaped_hole(hole::VariableShapedHole) = true +contains_variable_shaped_hole(hole::Hole) = true #Shared reference to an empty vector to reduce memory allocations. @@ -444,7 +441,7 @@ NOCHILDREN = Vector{AbstractRuleNode}() Returns the children of the given [`AbstractRuleNode`](@ref) """ get_children(rn::AbstractRuleNode)::Vector{AbstractRuleNode} = rn.children -get_children(::VariableShapedHole)::Vector{AbstractRuleNode} = NOCHILDREN +get_children(::Hole)::Vector{AbstractRuleNode} = NOCHILDREN get_children(h::UniformHole)::Vector{AbstractRuleNode} = h.children @@ -454,7 +451,7 @@ get_children(h::UniformHole)::Vector{AbstractRuleNode} = h.children Returns true iff the children of the [`AbstractRuleNode`](@ref) are known. """ isfixedshaped(::RuleNode)::Bool = true -isfixedshaped(::VariableShapedHole)::Bool = false +isfixedshaped(::Hole)::Bool = false isfixedshaped(::UniformHole)::Bool = true @@ -466,7 +463,7 @@ Holes are considered to be "filled" iff their domain size is exactly 1. """ isfilled(rn::RuleNode)::Bool = true isfilled(hole::UniformHole)::Bool = (sum(hole.domain) == 1) -isfilled(hole::VariableShapedHole)::Bool = (sum(hole.domain) == 1) +isfilled(hole::Hole)::Bool = (sum(hole.domain) == 1) """ @@ -484,7 +481,7 @@ hasdynamicvalue(rn::AbstractRuleNode)::Bool = false Returns the index of the rule that this [`AbstractRuleNode`](@ref) represents """ get_rule(rn::RuleNode) = rn.ind -function get_rule(hole::Hole) +function get_rule(hole::AbstractHole) @assert isfilled(hole) "$(hole) is not filled, unable to get the rule" return findfirst(hole.domain) end @@ -500,7 +497,7 @@ RuleNode(3, [ ]) and RuleNode(9, [ RuleNode(2), - VariableShapedHole(domain) + Hole(domain) ]) have the same shape: 1 root with 2 children. """ diff --git a/test/runtests.jl b/test/runtests.jl index 44a0872..d932a96 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -40,8 +40,8 @@ using Test @test RuleNode(2) > RuleNode(1) @test RuleNode(1,[RuleNode(2)]) < RuleNode(1,[RuleNode(3)]) @test RuleNode(1,[RuleNode(2)]) < RuleNode(2,[RuleNode(1)]) - @test_throws ArgumentError RuleNode(1) < VariableShapedHole(BitVector((1, 1))) - @test_throws ArgumentError VariableShapedHole(BitVector((1, 1))) < RuleNode(1) + @test_throws ArgumentError RuleNode(1) < Hole(BitVector((1, 1))) + @test_throws ArgumentError Hole(BitVector((1, 1))) < RuleNode(1) end @testset "Node depth from a tree" begin @@ -141,13 +141,13 @@ using Test @testset "number_of_holes" begin domain=BitVector((1, 1)) @test number_of_holes(RuleNode(1)) == 0 - @test number_of_holes(VariableShapedHole(domain)) == 1 + @test number_of_holes(Hole(domain)) == 1 @test number_of_holes(UniformHole(domain, [RuleNode(1), RuleNode(1)])) == 1 - @test number_of_holes(UniformHole(domain, [VariableShapedHole(domain), RuleNode(1)])) == 2 - @test number_of_holes(RuleNode(2, [VariableShapedHole(domain), RuleNode(1)])) == 1 + @test number_of_holes(UniformHole(domain, [Hole(domain), RuleNode(1)])) == 2 + @test number_of_holes(RuleNode(2, [Hole(domain), RuleNode(1)])) == 1 @test number_of_holes(UniformHole(domain, [ - VariableShapedHole(domain), - UniformHole(domain, [VariableShapedHole(domain), RuleNode(1)]) + Hole(domain), + UniformHole(domain, [Hole(domain), RuleNode(1)]) ])) == 4 end @@ -161,7 +161,7 @@ using Test @test isfixedshaped(RuleNode(1, [])) == true @test isfixedshaped(UniformHole(domain, [])) == true - @test isfixedshaped(VariableShapedHole(domain)) == false + @test isfixedshaped(Hole(domain)) == false end @testset "isfilled" begin @@ -169,14 +169,14 @@ using Test domain2=BitVector((0, 1, 0, 1, 0)) @test isfilled(RuleNode(1, [])) == true @test isfilled(RuleNode(1, [RuleNode(2)])) == true - @test isfilled(RuleNode(1, [VariableShapedHole(domain1)])) == true - @test isfilled(RuleNode(1, [VariableShapedHole(domain2)])) == true + @test isfilled(RuleNode(1, [Hole(domain1)])) == true + @test isfilled(RuleNode(1, [Hole(domain2)])) == true - @test isfilled(UniformHole(domain1, [VariableShapedHole(domain2)])) == true - @test isfilled(UniformHole(domain2, [VariableShapedHole(domain2)])) == false + @test isfilled(UniformHole(domain1, [Hole(domain2)])) == true + @test isfilled(UniformHole(domain2, [Hole(domain2)])) == false - @test isfilled(VariableShapedHole(domain1)) == true - @test isfilled(VariableShapedHole(domain2)) == false + @test isfilled(Hole(domain1)) == true + @test isfilled(Hole(domain2)) == false end @testset "get_rule" begin @@ -184,13 +184,13 @@ using Test @test get_rule(RuleNode(99, [RuleNode(3), RuleNode(4)])) == 99 @test get_rule(RuleNode(2, [RuleNode(3), RuleNode(4)])) == 2 @test get_rule(UniformHole(domain_of_size_1, [RuleNode(5), RuleNode(6)])) == 2 - @test get_rule(VariableShapedHole(domain_of_size_1)) == 2 + @test get_rule(Hole(domain_of_size_1)) == 2 end @testset "have_same_shape" begin domain = BitVector((1, 1, 1, 1, 1, 1, 1, 1, 1)) @test have_same_shape(RuleNode(1), RuleNode(2)) - @test have_same_shape(RuleNode(1), VariableShapedHole(domain)) + @test have_same_shape(RuleNode(1), Hole(domain)) @test have_same_shape(RuleNode(1), RuleNode(4, [RuleNode(1)])) == false @test have_same_shape(RuleNode(4, [RuleNode(1)]), RuleNode(1)) == false @@ -200,7 +200,7 @@ using Test ]) node2 = RuleNode(9, [ RuleNode(2), - VariableShapedHole(domain) + Hole(domain) ]) @test have_same_shape(node1, node2) @@ -223,7 +223,7 @@ using Test @test hasdynamicvalue(RuleNode(1)) == false @test hasdynamicvalue(UniformHole(BitVector((1, 0)), [RuleNode(1, "DynamicValue")])) == false @test hasdynamicvalue(UniformHole(BitVector((1, 0)), [RuleNode(1)])) == false - @test hasdynamicvalue(VariableShapedHole(BitVector((1, 0)))) == false + @test hasdynamicvalue(Hole(BitVector((1, 0)))) == false end end end