Skip to content

Allow passing shards to zarr.zeros #3571

Open

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'

Activity

  1. d-v-b commented on Nov 6, 2025

    @d-v-b
    Contributor

    looks like these methods need to target create_array instead of create

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions