8000 consistent advanced slicing · Issue #16978 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
consistent advanced slicing #16978
Closed
Closed
@2sn

Description

@2sn

Reproducing code example:

>>> import numpy as np
>>> a = np.ndarray((5,6,7))
>>> a.shape
(5, 6, 7)
>>> a[[[0,1]],[[0],[1],[2]],:].shape
(3, 2, 7)
>>> a[:,[[0,1]],[[0],[1],[2]]].shape
(5, 3, 2)
>>> a[[[0,1]],:,[[0],[1],[2]]].shape
(3, 2, 6)

I think the outcome of the third example is unexpected and inconsistent having seen the first two. I it would be more consistent either have the index dimensions (3,2) always be first, or preserve location of the "free" coordinate : to obtain a shape of (3,6,2).

Numpy/Python version information:

1.19.1 3.8.4 (default, Jul 14 2020, 11:50:51)
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]

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