Skip to content

[v3] Support zero-dimensional arrays #1976

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

Closed
tomwhite opened this issue Jun 18, 2024 · 2 comments
Closed

[v3] Support zero-dimensional arrays #1976

tomwhite opened this issue Jun 18, 2024 · 2 comments
Assignees
Labels
bug Potential issues with the zarr-python library
Milestone

Comments

@tomwhite
Copy link
Contributor

Zarr version

3.0.0a1

Numcodecs version

0.12.1

Python Version

3.11.9

Operating System

Mac

Installation

pip

Description

Zero-dimensional arrays are supported in v2, so they should be in v3 too.

Steps to reproduce

>>> import zarr.v2 as zarr
>>> z = zarr.open(store='example-v2.zarr', mode='w', shape=())
>>> z[...] = 2
>>> z[...]
array(2.)
>>> import zarr
>>> z = zarr.open(store='example-v3.zarr', mode='w', shape=())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tom/workspace/zarr-python/src/zarr/api/synchronous.py", line 45, in open
    obj = sync(
          ^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/sync.py", line 92, in sync
    raise return_result
  File "/Users/tom/workspace/zarr-python/src/zarr/sync.py", line 51, in _runner
    return await coro
           ^^^^^^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/api/asynchronous.py", line 198, in open
    return await open_array(store=store_path, zarr_format=zarr_format, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/api/asynchronous.py", line 868, in open_array
    return await create(store=store, path=path, zarr_format=zarr_format, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/api/asynchronous.py", line 686, in create
    return await AsyncArray.create(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/array.py", line 153, in create
    return await cls._create_v3(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/array.py", line 237, in _create_v3
    chunk_grid=RegularChunkGrid(chunk_shape=chunk_shape),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/chunk_grids.py", line 51, in __init__
    chunk_shape_parsed = parse_shapelike(chunk_shape)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/workspace/zarr-python/src/zarr/common.py", line 145, in parse_shapelike
    raise ValueError("Expected at least one element. Got 0.")
ValueError: Expected at least one element. Got 0.

Additional output

No response

@tomwhite tomwhite added the bug Potential issues with the zarr-python library label Jun 18, 2024
@d-v-b d-v-b self-assigned this Jun 18, 2024
@d-v-b
Copy link
Contributor

d-v-b commented Jun 18, 2024

thanks for the bug report! On the array creation side I think this will be an easy fix, and hopefully our port of the v2 indexing routines preserves the expected behavior there.

@d-v-b d-v-b mentioned this issue Jun 18, 2024
6 tasks
@tomwhite tomwhite mentioned this issue Jun 18, 2024
6 tasks
@jhamman jhamman added the V3 label Jun 18, 2024
@jhamman jhamman added this to the 3.0.0 milestone Jun 18, 2024
@tomwhite
Copy link
Contributor Author

This now works with #1979 and #1980 - thanks @d-v-b!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

No branches or pull requests

3 participants