You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
>>>importnumpyasnp>>>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]
The text was updated successfully, but these errors were encountered:
As a reminder of why this matters; I think we concluded that it was undefined behavior for an array to contain a pointer to unallocated memory (which I think b[1:] does in your example); while in practice this doesn't seem to matter today, a future GCC optimization would be free to break things in arbitrary and possibly silent ways.
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.
NumPy/Python version information:
1.23.0 3.10.0 (default, Oct 15 2021, 11:40:42) [GCC 7.5.0]
The text was updated successfully, but these errors were encountered: