Skip to content

Commit

Permalink
Change saving order from F to C (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 authored Nov 27, 2023
1 parent 809e231 commit 04dd43e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SmallZarrGroups"
uuid = "d423b6e5-1c84-4ae2-8d2d-b903aee15ac7"
authors = ["nhz2 <[email protected]>"]
version = "0.7.1"
version = "0.8.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand All @@ -25,5 +25,5 @@ DataStructures = "0.18"
JSON3 = "1"
StructArrays = "0.6"
TranscodingStreams = "0.9, 0.10"
ZipArchives = "0.3, 0.4, 0.5, 1"
ZipArchives = "1"
julia = "1.8"
2 changes: 1 addition & 1 deletion src/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function load_dir(reader::AbstractReader)::ZGroup
end
end

zarray = if metadata.is_column_major
zarray = if metadata.is_column_major || ndims(array) 1
ZArray(array;
chunks = Tuple(chunks),
compressor = metadata.compressor,
Expand Down
7 changes: 4 additions & 3 deletions src/saving.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function _save_zarray(writer::AbstractWriter, key_prefix::String, z::ZArray)
if zarr_size != 0 && !any(iszero, shape)
chunks = Tuple(z.chunks)
# store chunks
shaped_chunkdata = zeros(UInt8, zarr_size, chunks...)
shaped_chunkdata = zeros(UInt8, zarr_size, reverse(chunks)...)
permuted_shaped_chunkdata = PermutedDimsArray(shaped_chunkdata, (1, ndims(z)+1:-1:2...))
shaped_array = if dtype.julia_size == 1
reshape(reinterpret(reshape, UInt8, data), 1, shape...)
else
Expand All @@ -102,7 +103,7 @@ function _save_zarray(writer::AbstractWriter, key_prefix::String, z::ZArray)
real_chunksize = chunkstop .- chunkstart .+ 1
# now create overlapping views
array_view = view(shaped_array, :, (range.(chunkstart, chunkstop))...)
chunk_view = view(shaped_chunkdata, :, (range.(1, real_chunksize))...)
chunk_view = view(permuted_shaped_chunkdata, :, (range.(1, real_chunksize))...)
# TODO check if the data can just be directly copied.
for (zarr_byte, julia_byte) in enumerate(dtype.byteorder)
selectdim(chunk_view, 1, zarr_byte) .= selectdim(array_view, 1, julia_byte)
Expand All @@ -122,7 +123,7 @@ function _save_zarray(writer::AbstractWriter, key_prefix::String, z::ZArray)
"dtype": $dtype_str,
"fill_value": null,
"filters": null,
"order": "F",
"order": "C",
"shape": [$(join(shape, ", "))],
"zarr_format": 2
}
Expand Down

2 comments on commit 04dd43e

@nhz2
Copy link
Member Author

@nhz2 nhz2 commented on 04dd43e Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96013

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.0 -m "<description of version>" 04dd43eedbdd8fc9fd6945c1958f0927b11c2ea6
git push origin v0.8.0

Please sign in to comment.