Reading and writing scalar arrays #1631
TomNicholas
started this conversation in
General
Replies: 1 comment 5 replies
-
to achieve the goal of changing the array in-place, you can use the |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was trying to change the values of all the arrays in a zarr store in-place (to alter their dtype), but kept getting tripped up when one of the arrays was a scalar.
As far as I can tell from the documentation the recommended way to read a zarr array into an in-memory numpy array is to slice it, i.e.
But this will raise an indexing error if a scalar is stored at
store['key']
!I managed to load the scalar by doing
but when I later want to overwrite the scalar in the store with some new values, I hit the same indexing error (and the
np.array
constructor trick can't help me here)This shouldn't happen - scalars are special cases of arrays, so anything that works for an N-D array should also work for a 0-D array.
Perhaps there is another method that I've missed, but then it should be linked to in the Reading and Writing Data section of the tutorial page.
I think this also relates to the discussion in #1603 - this problem only comes up because the
[:]
syntax for loading is itself a bit of an abuse of how slicing is supposed to work (see the argument about typing in that thread).EDIT: Apparently my use case doesn't have a simple solution 😞 #1444
Beta Was this translation helpful? Give feedback.
All reactions