From c6570bc5eb2d15e531d1336a05c27295d6c4ae82 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Tue, 3 Feb 2026 13:32:57 -0800 Subject: [PATCH 1/3] chore: explicit imports --- src/ASDF.jl | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ASDF.jl b/src/ASDF.jl index a38f7b5..1fe903e 100644 --- a/src/ASDF.jl +++ b/src/ASDF.jl @@ -1,16 +1,15 @@ module ASDF -using BlockArrays -using CodecXz -using ChunkCodecLibBlosc -using ChunkCodecLibBzip2 -using ChunkCodecLibLz4 -using ChunkCodecLibZlib -using ChunkCodecLibZstd -using MD5 -using PkgVersion -using StridedViews -using YAML +using ChunkCodecLibBlosc: BloscCodec, BloscEncodeOptions +using ChunkCodecLibBzip2: BZ2Codec, BZ2EncodeOptions +using ChunkCodecLibLz4: LZ4FrameCodec, LZ4FrameEncodeOptions +using ChunkCodecLibZlib: ZlibCodec, ZlibEncodeOptions +using ChunkCodecLibZstd: ZstdCodec, ZstdEncodeOptions, decode, encode +using CodecXz: XzCompressor, XzDecompressor +using MD5: md5 +using PkgVersion: PkgVersion +using StridedViews: StridedView +using YAML: YAML ################################################################################ From 14ca499917d831a7a27ccdf85e175445baa2ecaf Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Tue, 3 Feb 2026 13:33:41 -0800 Subject: [PATCH 2/3] test: use ParallelTestRunner.jl --- .github/workflows/CI.yml | 2 + test/Project.toml | 3 + test/runtests.jl | 118 +++++++------------------------------- test/test-aqua.jl | 4 ++ test/test-read.jl | 20 +++++++ test/test-read_chunked.jl | 16 ++++++ test/test-write.jl | 43 ++++++++++++++ 7 files changed, 108 insertions(+), 98 deletions(-) create mode 100644 test/test-aqua.jl create mode 100644 test/test-read.jl create mode 100644 test/test-read_chunked.jl create mode 100644 test/test-write.jl diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9b67b78..25c8c81 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,6 +27,8 @@ jobs: - uses: julia-actions/cache@v2 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 + with: + test_args: '--verbose' - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v5 with: diff --git a/test/Project.toml b/test/Project.toml index 2a96263..c7f25f6 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,3 +1,6 @@ [deps] +ASDF = "686f71d1-807d-59a4-a860-28280ea06d7b" +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" diff --git a/test/runtests.jl b/test/runtests.jl index 3f58e8c..760c4b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,103 +1,25 @@ +using ParallelTestRunner: runtests, find_tests, parse_args using ASDF -using Test -using YAML -map_tree(f, x) = f(x) -map_tree(f, vec::AbstractVector) = [map_tree(f, elem) for elem in vec] -map_tree(f, dict::AbstractDict) = Dict(key => map_tree(f, val) for (key, val) in dict) - -output(x) = nothing -function output(arr::ASDF.NDArray) - println("source: $(arr.source)") - data = arr[] - println(" type: $(typeof(data))") - return println(" size: $(size(data))") -end - -################################################################################ - -@testset "Read ASDF file" begin - asdf = ASDF.load_file("blue_upchan_gain.00000000.asdf") - println(YAML.write(asdf.metadata)) - - map_tree(output, asdf.metadata) - - buffer = asdf.metadata[0]["buffer"][] - @test eltype(buffer) == Float16 - @test size(buffer) == (256,) - @test buffer == fill(1, 256) - - dish_index = asdf.metadata[0]["dish_index"][] - @test eltype(dish_index) == Int32 - @test size(dish_index) == (3, 2) - @test dish_index == [ - -1 -1 - 42 53 - 43 54 - ] -end - -################################################################################ - -@testset "Read ASDF file with chunked arrays" begin - asdf = ASDF.load_file("chunking.asdf") - println(YAML.write(asdf.metadata)) - - map_tree(output, asdf.metadata) - - chunky = asdf.metadata["chunky"][] - @test eltype(chunky) == Float16 - @test size(chunky) == (4, 4) - @test chunky == [ - 11 21 31 41 - 12 22 32 42 - 13 23 33 43 - 14 24 34 44 - ] +const init_code = quote + using ASDF + using Test + using YAML + + map_tree(f, x) = f(x) + map_tree(f, vec::AbstractVector) = [map_tree(f, elem) for elem in vec] + map_tree(f, dict::AbstractDict) = Dict(key => map_tree(f, val) for (key, val) in dict) + + output(x) = nothing + function output(arr::ASDF.NDArray) + println("source: $(arr.source)") + data = arr[] + println(" type: $(typeof(data))") + return println(" size: $(size(data))") + end end -################################################################################ - -@testset "Write ASDF file" begin - dirname = mktempdir(; cleanup=true) - filename = joinpath(dirname, "output.asdf") - - array = Float64[1/(i+j+k-2) for i in 1:50, j in 1:51, k in 1:52] - doc = Dict{Any,Any}( - "data1" => ASDF.NDArrayWrapper([1 2; 3 4]; inline=false), - "data2" => ASDF.NDArrayWrapper([1 2; 3 4]; inline=true), - "group" => Dict{Any,Any}( - "element1" => ASDF.NDArrayWrapper(array; compression=ASDF.C_None), - "element2" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Blosc), - "element3" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Bzip2), - "element4" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Lz4), - "element5" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Xz), - "element6" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Zlib), - "element7" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Zstd), - ), - ) - ASDF.write_file(filename, doc) +args = parse_args(Base.ARGS) +testsuite = find_tests(@__DIR__) - doc′ = ASDF.load_file(filename) - map_tree(output, doc′.metadata) - - data1 = doc["data1"][] - data1′ = doc′.metadata["data1"][] - @test eltype(data1′) == eltype(data1) - @test size(data1′) == size(data1) - @test data1′ == data1 - - data2 = doc["data2"][] - data2′ = doc′.metadata["data2"][] - @test eltype(data2′) == eltype(data2) - @test size(data2′) == size(data2) - @test data2′ == data2 - - for n in 1:7 - element = doc["group"]["element$n"][] - element′ = doc′.metadata["group"]["element$n"][] - @test eltype(element′) == eltype(element) - @test size(element′) == size(element) - @test element′ == element - end -end +runtests(ASDF, args; testsuite, init_code) diff --git a/test/test-aqua.jl b/test/test-aqua.jl new file mode 100644 index 0000000..2a9e231 --- /dev/null +++ b/test/test-aqua.jl @@ -0,0 +1,4 @@ +@testset "Aqua" begin + using ASDF, Aqua + Aqua.test_all(ASDF) +end diff --git a/test/test-read.jl b/test/test-read.jl new file mode 100644 index 0000000..94f6bc3 --- /dev/null +++ b/test/test-read.jl @@ -0,0 +1,20 @@ +@testset "Read ASDF file" begin + asdf = ASDF.load_file("blue_upchan_gain.00000000.asdf") + println(YAML.write(asdf.metadata)) + + map_tree(output, asdf.metadata) + + buffer = asdf.metadata[0]["buffer"][] + @test eltype(buffer) == Float16 + @test size(buffer) == (256,) + @test buffer == fill(1, 256) + + dish_index = asdf.metadata[0]["dish_index"][] + @test eltype(dish_index) == Int32 + @test size(dish_index) == (3, 2) + @test dish_index == [ + -1 -1 + 42 53 + 43 54 + ] +end diff --git a/test/test-read_chunked.jl b/test/test-read_chunked.jl new file mode 100644 index 0000000..b7a101c --- /dev/null +++ b/test/test-read_chunked.jl @@ -0,0 +1,16 @@ +@testset "Read ASDF file with chunked arrays" begin + asdf = ASDF.load_file("chunking.asdf") + println(YAML.write(asdf.metadata)) + + map_tree(output, asdf.metadata) + + chunky = asdf.metadata["chunky"][] + @test eltype(chunky) == Float16 + @test size(chunky) == (4, 4) + @test chunky == [ + 11 21 31 41 + 12 22 32 42 + 13 23 33 43 + 14 24 34 44 + ] +end diff --git a/test/test-write.jl b/test/test-write.jl new file mode 100644 index 0000000..86b5b81 --- /dev/null +++ b/test/test-write.jl @@ -0,0 +1,43 @@ +@testset "Write ASDF file" begin + dirname = mktempdir(; cleanup=true) + filename = joinpath(dirname, "output.asdf") + + array = Float64[1/(i+j+k-2) for i in 1:50, j in 1:51, k in 1:52] + doc = Dict{Any,Any}( + "data1" => ASDF.NDArrayWrapper([1 2; 3 4]; inline=false), + "data2" => ASDF.NDArrayWrapper([1 2; 3 4]; inline=true), + "group" => Dict{Any,Any}( + "element1" => ASDF.NDArrayWrapper(array; compression=ASDF.C_None), + "element2" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Blosc), + "element3" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Bzip2), + "element4" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Lz4), + "element5" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Xz), + "element6" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Zlib), + "element7" => ASDF.NDArrayWrapper(array; compression=ASDF.C_Zstd), + ), + ) + ASDF.write_file(filename, doc) + + doc′ = ASDF.load_file(filename) + map_tree(output, doc′.metadata) + + data1 = doc["data1"][] + data1′ = doc′.metadata["data1"][] + @test eltype(data1′) == eltype(data1) + @test size(data1′) == size(data1) + @test data1′ == data1 + + data2 = doc["data2"][] + data2′ = doc′.metadata["data2"][] + @test eltype(data2′) == eltype(data2) + @test size(data2′) == size(data2) + @test data2′ == data2 + + for n in 1:7 + element = doc["group"]["element$n"][] + element′ = doc′.metadata["group"]["element$n"][] + @test eltype(element′) == eltype(element) + @test size(element′) == size(element) + @test element′ == element + end +end From 0d7ad6c92177cc8283d27f41796a5cd4bac68980 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Tue, 3 Feb 2026 13:33:55 -0800 Subject: [PATCH 3/3] chore: use [workspace] --- Project.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 058dbf8..0938fed 100644 --- a/Project.toml +++ b/Project.toml @@ -1,10 +1,12 @@ name = "ASDF" uuid = "686f71d1-807d-59a4-a860-28280ea06d7b" -authors = ["Erik Schnetter "] version = "2.0.0" +authors = ["Erik Schnetter "] + +[workspace] +projects = ["test", "docs"] [deps] -BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" ChunkCodecLibBlosc = "c6a955be-ab7f-4fbb-b38f-caf93db6b928" ChunkCodecLibBzip2 = "2b723af9-f480-4e8d-a1e4-4a9f5a906122" ChunkCodecLibLz4 = "7e9cc85e-5614-42a3-ad86-b78f920b38a5" @@ -17,7 +19,6 @@ StridedViews = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143" YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" [compat] -BlockArrays = "0.16.43, 1" ChunkCodecLibBlosc = "0.2.0" ChunkCodecLibBzip2 = "0.2.0" ChunkCodecLibLz4 = "0.2.1"