Skip to content

Commit 7e551de

Browse files
committed
IO tests are only run for latest Julia version
1 parent 89a231f commit 7e551de

2 files changed

Lines changed: 62 additions & 53 deletions

File tree

test/hierarchical_utils.jl

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -145,50 +145,54 @@ end
145145
@test NodeIterator(n2, n2m) |> collect == collect(zip(NodeIterator(n2) |> collect, NodeIterator(n2m) |> collect))
146146
end
147147

148-
@testset "printtree" begin
149-
@test buf_printtree(n2, trav=true) ==
150-
"""
151-
ProductNode [""] 2 obs, 0 bytes
152-
├── ProductNode ["E"] 2 obs, 0 bytes
153-
│ ├─── b: BagNode ["I"] 2 obs, 176 bytes
154-
│ │ ╰── ArrayNode(3×4 Array with Float32 elements) ["K"] 4 obs, 104 bytes
155-
│ ╰── wb: WeightedBagNode ["M"] 2 obs, 240 bytes
156-
│ ╰── ArrayNode(17×4 NGramMatrix with Int64 elements) ["O"] 4 obs, 154 bytes
157-
╰── ArrayNode(10×2 SparseMatrixCSC with Float32 elements) ["U"] 2 obs, 424 bytes
158-
"""
159-
160-
@test buf_printtree(n2m, trav=true) ==
161-
"""
162-
ProductModel ↦ Dense(20 => 10) [""] 2 arrays, 210 params, 928 bytes
163-
├── ProductModel ↦ Dense(20 => 10) ["E"] 2 arrays, 210 params, 928 bytes
164-
│ ├─── b: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["I"] 4 arrays, 240 params, 1.102 KiB
165-
│ │ ╰── ArrayModel(Dense(3 => 10)) ["K"] 2 arrays, 40 params, 248 bytes
166-
│ ╰── wb: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["M"] 4 arrays, 240 params, 1.102 KiB
167-
│ ╰── ArrayModel(Dense(17 => 10)) ["O"] 2 arrays, 180 params, 808 bytes
168-
╰── ArrayModel(Dense(10 => 10)) ["U"] 2 arrays, 110 params, 528 bytes
169-
"""
170-
end
171-
172-
@testset "LazyNode" begin
173-
ds = LazyNode{:Codons}(ss)
174-
m = Mill.reflectinmodel(ds)
175-
@test nchildren(ds) == 4
176-
@test nleafs(ds) == 4
177-
@test nnodes(ds) == 5
178-
179-
@test buf_printtree(ds, trav=true) ==
180-
"""
181-
LazyNode{Codons}(String) [""] 4 obs, 8 bytes
182-
├── "GGGCGGCGA" ["6"]
183-
├── "CCTCGCGGG" ["E"]
184-
├── "TTTTCGCTATTTATGAAAATT" ["M"]
185-
╰── "TTCCGGTTTAAGGCGTTTCCG" ["U"]
186-
"""
187-
188-
@test buf_printtree(m, trav=true) ==
189-
"""
190-
LazyModel{Codons} [""]
191-
╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["U"] 4 arrays, 240 params, 1.102 KiB
192-
╰── ArrayModel(Dense(64 => 10)) ["k"] 2 arrays, 650 params, 2.625 KiB
193-
"""
148+
@static if VERSION v"1.11.0"
149+
@testset "printtree" begin
150+
@test buf_printtree(n2, trav=true) ==
151+
"""
152+
ProductNode [""] 2 obs, 0 bytes
153+
├── ProductNode ["E"] 2 obs, 0 bytes
154+
│ ├─── b: BagNode ["I"] 2 obs, 176 bytes
155+
│ │ ╰── ArrayNode(3×4 Array with Float32 elements) ["K"] 4 obs, 104 bytes
156+
│ ╰── wb: WeightedBagNode ["M"] 2 obs, 240 bytes
157+
│ ╰── ArrayNode(17×4 NGramMatrix with Int64 elements) ["O"] 4 obs, 154 bytes
158+
╰── ArrayNode(10×2 SparseMatrixCSC with Float32 elements) ["U"] 2 obs, 424 bytes
159+
"""
160+
161+
@test buf_printtree(n2m, trav=true) ==
162+
"""
163+
ProductModel ↦ Dense(20 => 10) [""] 2 arrays, 210 params, 928 bytes
164+
├── ProductModel ↦ Dense(20 => 10) ["E"] 2 arrays, 210 params, 928 bytes
165+
│ ├─── b: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["I"] 4 arrays, 240 params, 1.102 KiB
166+
│ │ ╰── ArrayModel(Dense(3 => 10)) ["K"] 2 arrays, 40 params, 248 bytes
167+
│ ╰── wb: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["M"] 4 arrays, 240 params, 1.102 KiB
168+
│ ╰── ArrayModel(Dense(17 => 10)) ["O"] 2 arrays, 180 params, 808 bytes
169+
╰── ArrayModel(Dense(10 => 10)) ["U"] 2 arrays, 110 params, 528 bytes
170+
"""
171+
end
172+
end
173+
174+
@static if VERSION v"1.11.0"
175+
@testset "LazyNode" begin
176+
ds = LazyNode{:Codons}(ss)
177+
m = Mill.reflectinmodel(ds)
178+
@test nchildren(ds) == 4
179+
@test nleafs(ds) == 4
180+
@test nnodes(ds) == 5
181+
182+
@test buf_printtree(ds, trav=true) ==
183+
"""
184+
LazyNode{Codons}(String) [""] 4 obs, 8 bytes
185+
├── "GGGCGGCGA" ["6"]
186+
├── "CCTCGCGGG" ["E"]
187+
├── "TTTTCGCTATTTATGAAAATT" ["M"]
188+
╰── "TTCCGGTTTAAGGCGTTTCCG" ["U"]
189+
"""
190+
191+
@test buf_printtree(m, trav=true) ==
192+
"""
193+
LazyModel{Codons} [""]
194+
╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["U"] 4 arrays, 240 params, 1.102 KiB
195+
╰── ArrayModel(Dense(64 => 10)) ["k"] 2 arrays, 650 params, 2.625 KiB
196+
"""
197+
end
194198
end

test/runtests.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,22 @@ function Mill.unpack2mill(ds::LazyNode{:Sentence})
9090
BagNode(x, Mill.length2bags(length.(s)))
9191
end
9292

93-
@testset "Doctests" begin
94-
DocMeta.setdocmeta!(Mill, :DocTestSetup, quote
95-
using Mill, Flux, Random, SparseArrays, Accessors, HierarchicalUtils
96-
# do not shorten prints in doctests
97-
ENV["LINES"] = ENV["COLUMNS"] = typemax(Int)
98-
end; recursive=true)
99-
doctest(Mill)
93+
@static if VERSION v"1.11.0"
94+
@testset "Doctests" begin
95+
DocMeta.setdocmeta!(Mill, :DocTestSetup, quote
96+
using Mill, Flux, Random, SparseArrays, Accessors, HierarchicalUtils
97+
# do not shorten prints in doctests
98+
ENV["LINES"] = ENV["COLUMNS"] = typemax(Int)
99+
end; recursive=true)
100+
doctest(Mill)
101+
end
100102
end
101103

102104
for test_f in readdir(".")
103105
(endswith(test_f, ".jl") && test_f "runtests.jl") || continue
106+
@static if VERSION < v"1.11.0"
107+
test_f == "io.jl" && continue
108+
end
104109
@testset verbose = true "$test_f" begin
105110
include(test_f)
106111
end

0 commit comments

Comments
 (0)