Skip to content
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

add ZArray to ZGroup arrays dict in zcreate #21

Merged
merged 2 commits into from
Dec 16, 2019
Merged

add ZArray to ZGroup arrays dict in zcreate #21

merged 2 commits into from
Dec 16, 2019

Conversation

visr
Copy link
Collaborator

@visr visr commented Dec 16, 2019

I created a group with a few arrays like so:

using Zarr

nrow = 1300
ncol = 1200
cellsize = 250.0
zpath = "data/chloride.zarr"

"Prepare an empty Zarr group with populated axes"
function prepare_zarr(path, nrow, ncol, cellsize)
    # only use compression on the data, not on the axes
    compressor = Zarr.BloscCompressor()
    # remove possible old zarr
    rm(path, force = true, recursive = true)
    store = DirectoryStore(path)
    group = zgroup(store)
    zchloride = Zarr.zcreate(
        Float64,
        group,
        "chloride",
        nrow,
        ncol;
        chunks = (100, 100),
        compressor = compressor,
    )
    zx = Zarr.zcreate(Float64, group, "x", ncol; compressor = Zarr.NoCompressor())
    zy = Zarr.zcreate(Float64, group, "y", nrow; compressor = Zarr.NoCompressor())
    zx[:] = range(cellsize / 2, step = cellsize, length = ncol)
    zy[:] = range(625000 - cellsize / 2, step = -250.0, length = nrow)
    return group
end

group = prepare_zarr(zpath, nrow, ncol, cellsize)

But was surprised to find that I could not retrieve the arrays from the group with group["chloride"]. This was because g.arrays (used by getindex) was empty. This commit populates g.arrays during zcreate.

@meggart
Copy link
Collaborator

meggart commented Dec 16, 2019

Of course, thanks for the fix. I will merge although this fails on nightly, let's find out later what has happened. Would you mind to increase the patch version number so that we can make a release with this fix, it might affect other users as well.

@visr
Copy link
Collaborator Author

visr commented Dec 16, 2019

Ok, thanks, I bumped the patch as well.

@visr visr merged commit fef7be9 into master Dec 16, 2019
@visr visr deleted the group branch December 16, 2019 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants