Skip to content

Change in indexing behaviour with numpy ints #967

@benjeffery

Description

@benjeffery

After 7c31f04 there was a breaking change to indexing behavior when a numpy integer type is passed:

For the following array:

z = zarr.group()
a = z.create_dataset("test",shape=(10,))
a[:]=range(10)

Before this commit:
a[np.int64(1)] has the value 1.0
After:
a[np.int64(1)] has the value [1.]

For both cases a[1] stays as 1.0 as expected. Was this change expected? This happens a lot when iterating over one numpy array and indexing with it as the iterable is of the numpy type. The fix in our application was to cast to a python int before indexing.

EDIT: Also note that numpy indexing returns the single value as was the case before this commit.

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