From d9e03343b703cde9c025785a7a51af04a097505f Mon Sep 17 00:00:00 2001 From: Reuben Gardos Reid <5456207+ReubenJ@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:20:38 +0200 Subject: [PATCH] `get_node_path` -> `get_path` --- src/HerbCore.jl | 2 +- src/rulenode.jl | 6 +++--- test/runtests.jl | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/HerbCore.jl b/src/HerbCore.jl index 0fcad58..dd48c9c 100644 --- a/src/HerbCore.jl +++ b/src/HerbCore.jl @@ -17,7 +17,7 @@ export get_rulesequence, rulesonleft, get_node_at_location, - get_node_path, + get_path, number_of_holes, contains_hole, contains_nonuniform_hole, diff --git a/src/rulenode.jl b/src/rulenode.jl index f02096c..89bcec8 100644 --- a/src/rulenode.jl +++ b/src/rulenode.jl @@ -387,17 +387,17 @@ function get_node_at_location(root::Hole, location::Vector{Int}) end """ - get_node_path(root::AbstractRuleNode, node::AbstractRuleNode) + get_path(root::AbstractRuleNode, node::AbstractRuleNode) Returns the path from the `root` to the `targetnode`. Returns nothing if no path exists. """ -function get_node_path( +function get_path( root::AbstractRuleNode, targetnode::AbstractRuleNode)::Union{Vector{Int}, Nothing} if root === targetnode return Vector{Int}() end for (i, child) in enumerate(get_children(root)) - path = get_node_path(child, targetnode) + path = get_path(child, targetnode) if !isnothing(path) return prepend!(path, i) end diff --git a/test/runtests.jl b/test/runtests.jl index 0e31b05..fd344cb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -104,7 +104,7 @@ using Test @test get_node_at_location(rulenode, [2]).ind == 4 end - @testset "get_node_path" begin + @testset "get_path" begin n1 = RuleNode(1) n2 = RuleNode(2) n3 = UniformHole(BitVector((1, 1, 1)), [RuleNode(1), n2]) @@ -116,10 +116,10 @@ using Test ]), n3 ]) - @test get_node_path(root, n1) == [1, 1] - @test get_node_path(root, n2) == [2, 2] - @test get_node_path(root, n3) == [2] - @test isnothing(get_node_path(root, n4)) + @test get_path(root, n1) == [1, 1] + @test get_path(root, n2) == [2, 2] + @test get_path(root, n3) == [2] + @test isnothing(get_path(root, n4)) end @testset "Length tests with holes" begin