-
-
Notifications
You must be signed in to change notification settings - Fork 370
0-dimensional arrays #161
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
0-dimensional arrays #161
Conversation
|
OK, I think this is good to go. |
|
|
||
| else: | ||
|
|
||
| out = self._decode_chunk(cdata) |
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.
Minor point. This seems a bit spaced out. Not sure if that was intentional or not.
|
Behaviour should be consistent with h5py and numpy, e.g.: >>> import zarr
>>> z = zarr.zeros(())
>>> z
<zarr.core.Array () float64>
>>> z[...]
array(0.0)
>>> z[()]
0.0
>>> z[...] = 42
>>> z[...]
array(42.0)
>>> z[()] = 43
>>> z[()]
43.0
>>> z[:]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aliman/src/github/alimanfoo/zarr/zarr/core.py", line 451, in __getitem__
return self._getitem_zd(item)
File "/home/aliman/src/github/alimanfoo/zarr/zarr/core.py", line 460, in _getitem_zd
raise IndexError('too many indices for array')
IndexError: too many indices for array |
| eq((), z.chunks) | ||
| eq(1, z.nchunks) | ||
| # compressor always None - no point in compressing a scalar value | ||
| assert_is_none(z.compressor) |
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.
Would it be worth checking nbytes as well or is that too far afield?
|
Does |
|
Thanks @jakirkham, have pushed some tweaks to tests and properties. |
|
Also can now set scalar on group: >>> import zarr
>>> g = zarr.group()
>>> g['foo'] = 42
>>> g['foo']
<zarr.core.Array '/foo' () int64>
>>> g['foo'][()]
42
>>> g['bar/baz/qux'] = 123.4
>>> g['bar/baz/qux']
<zarr.core.Array '/bar/baz/qux' () float64>
>>> g['bar/baz/qux'][()]
123.40000000000001 |
|
LGTM |
|
As a reminder to future selves, JuliaIO/Zarr.jl#117 |
This PR provides tests and implementation of support for 0-dimensional arrays. This builds off work done in #154, however I needed to add special case implementations of
__getitem__and__setitem__to theArrayclass to get indexing working with both empty tuple and ellipsis.