From dc2acc03cfd0670cee8aca541ba31d635e0f3892 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Thu, 6 Mar 2025 10:21:56 +0100 Subject: [PATCH 1/2] Add fill_value_decoding method for disambiguation --- src/metadata.jl | 1 + test/runtests.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/src/metadata.jl b/src/metadata.jl index d80e7c1..06c3791 100644 --- a/src/metadata.jl +++ b/src/metadata.jl @@ -224,6 +224,7 @@ fill_value_decoding(v::Nothing, ::Any) = v fill_value_decoding(v, T) = T(v) fill_value_decoding(v::Number, T::Type{String}) = v == 0 ? "" : T(UInt8[v]) fill_value_decoding(v, ::Type{ASCIIChar}) = v == "" ? nothing : v +fill_value_decoding(v::Nothing, ::Type{Zarr.ASCIIChar}) = v # Sometimes when translating between CF (climate and forecast) convention data # and Zarr groups, fill values are left as "negative integers" to encode unsigned # integers. So, we have to convert to the signed type with the same number of bytes diff --git a/test/runtests.jl b/test/runtests.jl index c472eb1..bc9b80f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -147,6 +147,7 @@ end @test Zarr.fill_value_decoding("-", String) === "-" @test Zarr.fill_value_decoding("", Zarr.ASCIIChar) === nothing @test Zarr.fill_value_decoding("", Zarr.MaxLengthString{6,UInt8}) === Zarr.MaxLengthString{6,UInt8}("") + @test Zarr.fill_value_decoding(nothing, Zarr.ASCIICHar) === nothing end end From c40a406c35698cc06e11553c31bbaebd30f6bdd4 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Thu, 6 Mar 2025 10:49:19 +0100 Subject: [PATCH 2/2] Fix typo --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index bc9b80f..0b4ea33 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -147,7 +147,7 @@ end @test Zarr.fill_value_decoding("-", String) === "-" @test Zarr.fill_value_decoding("", Zarr.ASCIIChar) === nothing @test Zarr.fill_value_decoding("", Zarr.MaxLengthString{6,UInt8}) === Zarr.MaxLengthString{6,UInt8}("") - @test Zarr.fill_value_decoding(nothing, Zarr.ASCIICHar) === nothing + @test Zarr.fill_value_decoding(nothing, Zarr.ASCIIChar) === nothing end end