Skip to content

BUG: subarray of a 4D array changed the order of axis #26752

Closed as not planned
Closed as not planned
@zexee

Description

@zexee

Describe the issue:

In [1]: import numpy as np

In [2]: a=np.zeros((2,3,4,5))

In [3]: a.shape
Out[3]: (2, 3, 4, 5)

In [4]: a[:, [True, False, False], :, :].shape
Out[4]: (2, 1, 4, 5)

In [5]: a[:, [True, False, False], :, 0].shape
Out[5]: (1, 2, 4) <-- look here, should it be (2, 1, 4)?

In [6]: a[:, [1], :, 0].shape
Out[6]: (1, 2, 4) <-- look here

Reproduce the code example:

import numpy as np
a=np.zeros((2,3,4,5))
print(a[:, [True, False, False], :, 0]).shape

output (1, 2, 4)

Error message:

No response

Python and NumPy Versions:

2.0.0
3.9.18 (main, Sep 7 2023, 00:00:00)
[GCC 11.4.1 20230605 (Red Hat 11.4.1-2)]

Runtime Environment:

No response

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    33 - QuestionQuestion about NumPy usage or development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions