-
-
Notifications
You must be signed in to change notification settings - Fork 329
resize(): Improve docs & control of what is modified #1017
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
Comments
@hailiangzhang, interesting. I can definitely understand your surprise. Reading https://zarr.readthedocs.io/en/stable/api/core.html?highlight=resize#zarr.core.Array.resize, however, it's only clear (at least for me) that out-of-bound chunks are removed not that the in-bound chunk is re-written. Assuming that's functionality that someone already relies on, it might take an extra argument to |
Ah, probably this is not very surprising based on the notes you provided:) So, in this case, I can add the testing to my PR as we originally planned. In the long term, as you mentioned above, probably we can add an extra argument to This being said, this issue report is more like a feature request instead a bug report, so please feel free to close it if there is no immediate plan to add this feature (or leave it here and someone may be able to add it when having a chance:). Thanks again for your comments @joshmoore ! |
Deletion can be fairly expensive so I think this was implemented intentionally to avoid deleting data and instead being a metadata only change (fairly quick). Maybe it is worth documenting that |
@jakirkham , agreed (and that's actually what I would imagine:) Since
If this looks correct and helpful, I will be happy to send another tiny PR:) |
👍 for the doc improvement. I've updated the title of this issue to:
with the control being potential new arguments, etc. |
Cool, I just sent a small PR which adds the comments as described above. |
Hi, since my PR has been merged, feel free to close this ticket (and please let me know if I am supposed to do that:) |
Happy to leave that up to you. If you think new method arguments are worth it, feel free to leave open. Otherwise, feel free to close. |
I found out that if you put every item in its own individual chunk, you will get the desired output after resizing. SAMPLE
OUTPUT Original zarr array with shape (4,6):
After resizing shape to (1,1):
Caveat: This is not optimal when dealing with a large data array and it will also create a huge number of files. |
Thanks for looking into this, @Jaykold. You're right that having a chunk size of 1 will work around the issue, but doing that for all dimensions with anything other than toy data isn't really an option. |
Problem description
For a zarr array with shape of
(4,6)
and chunksize of(2,3)
, I did the following:(1,1)
(4,6)
I found that the final array after step-2 brought back the original values in the first whole chunk.
However, as an end user, I am expecting only the first element to be preserved (since I had already shrunk the shape to be
(1,1)
, and the chunksize should be transparent to the end user).Minimal, reproducible code sample
Output
Version information
The text was updated successfully, but these errors were encountered: