Skip to content

given shape=(s,) chunks=(-1,) should mean (s,) #3898

@d-v-b

Description

@d-v-b

i.e., this should work and not error:

>>> zarr.create_array(store={}, shape=(10,), chunks=(-1,), dtype='uint8')
Traceback (most recent call last):
  File "<python-input-4>", line 1, in <module>
    zarr.create_array(store={}, shape=(10,), chunks=(-1,), dtype='uint8')
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/api/synchronous.py", line 963, in create_array
    sync(
    ~~~~^
        zarr.core.array.create_array(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<20 lines>...
        )
        ^
    )
    ^
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/core/sync.py", line 159, in sync
    raise return_result
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/core/sync.py", line 119, in _runner
    return await coro
           ^^^^^^^^^^
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/core/array.py", line 4907, in create_array
    return await init_array(
           ^^^^^^^^^^^^^^^^^
    ...<16 lines>...
    )
    ^
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/core/array.py", line 4721, in init_array
    meta = AsyncArray._create_metadata_v3(
        shape=shape_parsed,
    ...<6 lines>...
        attributes=attributes,
    )
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/core/array.py", line 777, in _create_metadata_v3
    chunk_grid_parsed = RegularChunkGrid(chunk_shape=chunk_shape)
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/core/chunk_grids.py", line 185, in __init__
    chunk_shape_parsed = parse_shapelike(chunk_shape)
  File "/Users/d-v-b/.cache/uv/archive-v0/G_mP5ruACDuVYUYdeRssH/lib/python3.13/site-packages/zarr/core/common.py", line 207, in parse_shapelike
    raise ValueError(msg)
ValueError: Expected all values to be non-negative. Got (-1,) instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions