Skip to content

Allow passing shards to zarr.zeros #3571

Description

@dstansby

zarr.zeros (and possibly other convenience functions) doesn't allow specifying shards; it would be nice if this was possible.

import zarr

zarr.zeros(shape=(10,), chunks=(2,), shards=(4,))
Traceback (most recent call last):
  File "/Users/dstansby/software/zarr/zarr-python/test.py", line 3, in <module>
    zarr.zeros(shape=(10,), chunks=(2,), shards=(4,))
  File "/Users/dstansby/software/zarr/zarr-python/src/zarr/api/synchronous.py", line 1441, in zeros
    return Array(sync(async_api.zeros(shape=shape, **kwargs)))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dstansby/software/zarr/zarr-python/src/zarr/core/sync.py", line 159, in sync
    raise return_result
  File "/Users/dstansby/software/zarr/zarr-python/src/zarr/core/sync.py", line 119, in _runner
    return await coro
           ^^^^^^^^^^
  File "/Users/dstansby/software/zarr/zarr-python/src/zarr/api/asynchronous.py", line 1353, in zeros
    return await create(shape=shape, fill_value=0, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dstansby/software/zarr/zarr-python/src/zarr/api/asynchronous.py", line 1087, in create
    return await AsyncArray._create(
                 ^^^^^^^^^^^^^^^^^^^
TypeError: AsyncArray._create() got an unexpected keyword argument 'shards'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions