8000 Request for fancy indexing · Issue #657 · zarr-developers/zarr-python · GitHub
[go: up one dir, main page]

Skip to content
Request for fancy indexing  #657
Closed
Closed
@AbigailMcGovern

Description

@AbigailMcGovern

Overview

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.0
  • numcodecs.__version__ --> 0.7.2
  • Version of Python interpreter --> 3.8.5
  • Operating system --> Mac
  • How Zarr was installed --> conda

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

      0