-
Notifications
You must be signed in to change notification settings - Fork 287
Support scalars in Zarr #3109
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
mannreis
wants to merge
3
commits into
Unidata:main
Choose a base branch
from
mannreis:3108
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Support scalars in Zarr #3109
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this
xarraybezvar->xarrayas in the following function call? I don't seexarraydefined here, though the compiler's not complaining, so it must be declared somewhere.If so, you might be able to make this if an else-if, using the previous `if (zvar->xarray == NULL) condition.
Otherwise, the code looks good, though I'm not familiar with Zarr or netCDF internals. Could you add a test for the desired behavior to ensure this change fixes the problem and that the problem stays fixed?
I'd also appreciate a more descriptive PR title, since I won't remember what issue #3108 was about while on the PR tab. Perhaps "Handle scalars in Zarr" or similar?
Also, what are your thoughts on the comment on line 1598 suggesting Zarr doesn't support scalars, is this still true? Do you think that check should be before this one? Would you still need to set
shapes?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xarrayis declared here:netcdf-c/libnczarr/zsync.c
Line 1398 in c4f84ee
and is set here:
netcdf-c/libnczarr/zsync.c
Line 1427 in c4f84ee
One could also check fot
zvar->xarray != NULLbutnclistlength(NULL)returns 0, so there's no need.Adding a test could be nice indeed! Will try to get that in (also contemplating the cases bellow).
Regarding Zarr not supporting scalars. I am not familiar with the specs, @DennisHeimbigner has a much better insight on it. To me it seems that if there is no dimensions for
shapesorchunksindataset.zarr/var/.zarray(or they are 0-length), then it could be a scalar. To get it's value, we check if there's at least one physical chunk on disk (dataset.zarr/var/0) or fallback into the default "FillValue".Using
zarr 2.18.2here is an example of the 2 cases where "scalars" (length 1 arrays) are stored:{ "chunks": [], "compressor": null, "dtype": "<i8", "fill_value": 0, "filters": null, "order": "C", "shape": [], "zarr_format": 2 } 8{ "chunks": [], "compressor": null, "dimension_separator": ".", "dtype": "<f8", "fill_value": 3.1415, "filters": null, "order": "C", "shape": [], "zarr_format": 2 } FileNotFoundError: [Errno 2] No such file or directory: 'z.zarr/pi/0'For the 2nd case, I think even this patch is not properly filling the scalar value: