Request for fancy indexing
See original GitHub issueOverview
Attempting to modify/retrive values in a zarr array with fancy indexing results in an error.
Minimal, reproducible code sample
For instance, a tuple of list indices
import zarr
array = zarr.zeros((20, 20))
array[[1, 2, 3], [1, 2, 3]] = 1
Results in the following:
IndexError: unsupported selection item for basic indexing; expected integer or slice, got <class 'list'>
However, this works usingvindex
array.vindex[[1, 2, 3], [1, 2, 3]] = 1
print(array.vindex[[1, 2, 3], [1, 2, 3]])
# Output: [1. 1. 1.]
Problem description
Zarr’s Array
class does not support fancy indexing via the standard numpy-like syntax, which causes issues when attempting to write to zarr arrays via napari’s label layer. These problems arise because several of the label editing tools in napari (e.g., paintbrush, fill tool, etc) require fancy indexing. @jni and myself are hoping that the logic in vindex can be incorporated to Array’s __setitem__
and __getitem__
. Any advice you can offer in this regard would be much appreciated!
Version and installation information
zarr.__version__
--> 2.4.0numcodecs.__version__
--> 0.7.2- Version of Python interpreter --> 3.8.5
- Operating system --> Mac
- How Zarr was installed --> conda
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Fancy Indexing | Python Data Science Handbook
Fancy indexing is conceptually simple: it means passing an array of indices to ... The at() method does an in-place application of the...
Read more >Fancy Indexing - Stanford University
Directory indexing will list the contents of the directory when the request is made. How to use fancy indexing. Actually, you don't have...
Read more >Fancy indexing with assignment for numpy array
Normally, when you use arrays to index another array this way, numpy expects each array R , C , and so on, to...
Read more >fancy indexing via a mix of NumPy array and list not working ...
The fancy indexing using a mix of NumPy boolean array and an explicit list does not seem to work in the latest h5py...
Read more >What is fancy indexing in NumPy? - Educative.io
Fancy indexing is a method used when working in arrays. It is an advanced form of simple indexing. An index is used to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closed by #725! 🎉
To be clear, Dask is not yet current consistent with NumPy, either, but that could be fixed: https://github.com/dask/dask/issues/7313. Thus I would advise caution before relying on this feature 😃