Skip to content
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

Regression in 2.18: Index to size-1 array fails #1883

Closed
AndreasAlbertQC opened this issue May 16, 2024 · 2 comments · Fixed by #1875
Closed

Regression in 2.18: Index to size-1 array fails #1883

AndreasAlbertQC opened this issue May 16, 2024 · 2 comments · Fixed by #1875
Labels
bug Potential issues with the zarr-python library

Comments

@AndreasAlbertQC
Copy link
Contributor

AndreasAlbertQC commented May 16, 2024

Zarr version

v2.18.0

Numcodecs version

v0.12.1

Python Version

3.11

Operating System

Reproduced on mac and linux

Installation

micromamba / conda-forge

Description

Indexing to unit-length arrays fails since zarr 2.18. Indexing other array lengths still works. See reproducer script and traceback below. In zarr 2.17, this still worked. I don't understand the problem exactly, but based on the 2.18 changelog, I would guess that this is somehow related to #1800

Steps to reproduce

import zarr
import numcodecs

assert zarr.__version__ == "2.18.0"
assert numcodecs.__version__ == "0.12.1"

x = zarr.array([1, 2])
y = zarr.array([1])

# OK
print(x[:])
print(y[:])

# OK
print(x[0])

# Not OK
print(y[0])

Additional output

Traceback (most recent call last):
  File "/Users/x/Library/Application Support/JetBrains/PyCharm2023.3/scratches/scratch_42.py", line 14, in <module>
    print(x[0])
          ~^^^
  File "/Users/x/micromamba/envs/envname/lib/python3.11/site-packages/zarr/core.py", line 800, in __getitem__
    result = self.get_basic_selection(pure_selection, fields=fields)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/x/micromamba/envs/envname/lib/python3.11/site-packages/zarr/core.py", line 926, in get_basic_selection
    return self._get_basic_selection_nd(selection=selection, out=out, fields=fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/x/micromamba/envs/envname/lib/python3.11/site-packages/zarr/core.py", line 968, in _get_basic_selection_nd
    return self._get_selection(indexer=indexer, out=out, fields=fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/x/micromamba/envs/envname/lib/python3.11/site-packages/zarr/core.py", line 1343, in _get_selection
    self._chunk_getitems(
  File "/Users/x/micromamba/envs/envname/lib/python3.11/site-packages/zarr/core.py", line 2181, in _chunk_getitems
    self._process_chunk(
  File "/Users/x/micromamba/envs/envname/lib/python3.11/site-packages/zarr/core.py", line 2049, in _process_chunk
    self._compressor.decode(cdata, dest)
  File "numcodecs/blosc.pyx", line 564, in numcodecs.blosc.Blosc.decode
  File "numcodecs/blosc.pyx", line 365, in numcodecs.blosc.decompress
  File "numcodecs/compat_ext.pyx", line 16, in numcodecs.compat_ext.Buffer.__cinit__
ValueError: buffer source array is read-only
@AndreasAlbertQC AndreasAlbertQC added the bug Potential issues with the zarr-python library label May 16, 2024
@jhamman
Copy link
Member

jhamman commented May 16, 2024

Thanks for reporting. This is likely the same as issue as #1874.

@AndreasAlbertQC
Copy link
Contributor Author

Thanks for the quick turnaround @jhamman , I appreciate it!

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

Successfully merging a pull request may close this issue.

2 participants