Skip to content

Reshaped 0-size arrays have non-zero strides #21918

@takagi

Description

@takagi

Describe the issue:

Since NumPy 1.23, the strides of empty (0 size) arrays are set to zero as changed in #21477. However, once such arrays are reshaped, the results have non-zero strides computed in a C-contiguous manner.

>>> import numpy as np
>>> a = np.ones((2, 0, 3))
>>> a.strides
(0, 0, 0)
>>> b = a.reshape((3, 0, 2))
>>> b.strides
(16, 16, 8)  # also should be (0, 0, 0)

NumPy/Python version information:

1.23.0 3.10.0 (default, Oct 15 2021, 11:40:42) [GCC 7.5.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions