Skip to content

Commit 44ec143

Browse files
authored
iterator order 0 (#78)
* allow rooted tree iterators with order zero * set version to v2.10.4
1 parent 65180a0 commit 44ec143

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RootedTrees"
22
uuid = "47965b36-3f3e-11e9-0dcf-4570dfd42a8c"
33
authors = ["Hendrik Ranocha <mail@ranocha.de> and contributors"]
4-
version = "2.10.3"
4+
version = "2.10.4"
55

66
[deps]
77
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"

src/RootedTrees.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Base.eltype(::Type{RootedTreeIterator{T}}) where T = RootedTree{T,Vector{T}}
500500

501501
@inline function Base.iterate(iter::RootedTreeIterator{T}) where {T}
502502
iter.t.level_sequence[:] = one(T):iter.order
503-
(iter.t, false)
503+
(iter.t, iter.order <= 0)
504504
end
505505

506506
@inline function Base.iterate(iter::RootedTreeIterator{T}, state) where {T}
@@ -537,7 +537,7 @@ end
537537
Counts all rooted trees of `order`.
538538
"""
539539
function count_trees(order)
540-
order < 1 && throw(ArgumentError("The `order` must be at least one."))
540+
order < 0 && throw(ArgumentError("The `order` must be at least zero."))
541541

542542
num = 0
543543
for _ in RootedTreeIterator(order)

test/runtests.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,13 @@ Plots.unicodeplots()
289289

290290
# see butcher2008numerical, Table 302(I)
291291
@testset "number of trees" begin
292-
number_of_rooted_trees = [1, 1, 2, 4, 9, 20, 48, 115, 286, 719]
293-
for order in 1:10
292+
number_of_rooted_trees = [1, 1, 1, 2, 4, 9, 20, 48, 115, 286, 719]
293+
for order in 0:10
294294
num = 0
295295
for t in RootedTreeIterator(order)
296296
num += 1
297297
end
298-
@test num == number_of_rooted_trees[order] == count_trees(order)
298+
@test num == number_of_rooted_trees[order + 1] == count_trees(order)
299299
end
300300
end
301301

@@ -785,15 +785,15 @@ end # @testset "RootedTree"
785785

786786
# see butcher2008numerical, Table 302(I)
787787
@testset "number of trees" begin
788-
number_of_rooted_trees = [1, 1, 2, 4, 9, 20, 48, 115, 286, 719]
789-
for order in 1:10
788+
number_of_rooted_trees = [1, 1, 1, 2, 4, 9, 20, 48, 115, 286, 719]
789+
for order in 0:10
790790
num = 0
791791
for t in BicoloredRootedTreeIterator(order)
792792
num += 1
793793
end
794794
# number of plain rooted trees times number of possible color sequences
795795
# <= since not all possible color sequences are in canonical representation
796-
@test num <= number_of_rooted_trees[order] * 2^order
796+
@test num <= number_of_rooted_trees[order + 1] * 2^order
797797
end
798798
end
799799

0 commit comments

Comments
 (0)