Skip to content

Fix reading complex type and add basic round trip test #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/metadata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const typemap = Dict{Tuple{Char, Int}, DataType}(
('U', 1) => Char,
)
sizemapf(x::Type{<:Number}) = sizeof(x)
sizemapf(x::Type{<:Complex{T}}) where T = sizeof(T)
typecharf(::Type{<:Signed}) = 'i'
typecharf(::Type{<:Unsigned}) = 'u'
typecharf(::Type{<:AbstractFloat}) = 'f'
Expand Down
23 changes: 18 additions & 5 deletions test/python.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ numeric_dtypes = (UInt8, UInt16, UInt32, UInt64,
dtypes = (numeric_dtypes...,
MaxLengthString{10,UInt8},MaxLengthString{10,UInt32},
String)
dtypesp = ("uint8","uint16","uint32","uint64",
"int8","int16","int32","int64",
"float16","float32","float64",
"complex64", "complex128","bool","S10","U10", "O")
compressors = (
"no"=>NoCompressor(),
"blosc"=>BloscCompressor(cname="zstd"),
Expand Down Expand Up @@ -79,6 +83,20 @@ open(pjulia*".zip";write=true) do io
Zarr.writezip(io, g)
end

@testset "reading in julia" begin
g = zopen(pjulia)
#Test group attributes
@test g.attrs == groupattrs
for i=1:length(dtypes), co in compressors
compstr,comp = co
t = dtypes[i]
arname = string("a",t,compstr)
ar=g[arname]
@test ar.attrs == Dict("This is a nested attribute"=>Dict("a"=>5))
@test ar == testarrays[t]
end
end

# Test reading in python
for julia_path in (pjulia, pjulia*".zip")
g = zarr.open_group(julia_path)
Expand All @@ -89,11 +107,6 @@ for julia_path in (pjulia, pjulia*".zip")
@test gatts["Int attribute"] == 5
@test gatts["Float attribute"] == 10.5

dtypesp = ("uint8","uint16","uint32","uint64",
"int8","int16","int32","int64",
"float16","float32","float64",
"complex64", "complex128","bool","S10","U10", "O")

#Test accessing arrays from python and reading data
for i=1:length(dtypes), co in compressors
compstr,comp = co
Expand Down
Loading