-
-
Notifications
You must be signed in to change notification settings - Fork 383
Open
Description
We support creating arrays with 0-sized chunks, but we error when accessing the values via __getitem__. Because the spec defines chunk sizes as non-zero integers, we should error at array creation time here.
>>> zarr.zeros(store={}, shape=(1,5,1), chunks=(1,2,0)).chunks
(1, 2, 0)
>>> zarr.zeros(store={}, shape=(1,5,1), chunks=(1,2,0))[:]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/d-v-b/dev/data-model-1/.venv/lib/python3.12/site-packages/zarr/core/array.py", line 2868, in __getitem__
return self.get_orthogonal_selection(pure_selection, fields=fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/d-v-b/dev/data-model-1/.venv/lib/python3.12/site-packages/zarr/core/array.py", line 3338, in get_orthogonal_selection
indexer = OrthogonalIndexer(selection, self.shape, self.metadata.chunk_grid)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/d-v-b/dev/data-model-1/.venv/lib/python3.12/site-packages/zarr/core/indexing.py", line 923, in __init__
dim_indexer = SliceDimIndexer(dim_sel, dim_len, dim_chunk_len)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/d-v-b/dev/data-model-1/.venv/lib/python3.12/site-packages/zarr/core/indexing.py", line 424, in __init__
object.__setattr__(self, "nchunks", ceildiv(dim_len, dim_chunk_len))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/d-v-b/dev/data-model-1/.venv/lib/python3.12/site-packages/zarr/core/common.py", line 94, in ceildiv
return math.ceil(a / b)
~~^~~
ZeroDivisionError: division by zeroThis will be a breaking change for anyone relied on the creation of these arrays.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels