forked from numpy/numpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request numpy#15882 from eric-wieser/reject-illegal-stride…
…s-in-ndarray.__new__ BUG: Do not ignore empty tuple of strides in ndarray.__new__
- Loading branch information
Showing
5 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The ``numpy.ndarray`` constructor no longer interprets ``strides=()`` as ``strides=None`` | ||
----------------------------------------------------------------------------------------- | ||
The former has changed to have the expected meaning of setting | ||
`numpy.ndarray.strides` to ``()``, while the latter continues to result in | ||
strides being chosen automatically. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ maintainer email: [email protected] | |
#include "arraytypes.h" | ||
#include "scalartypes.h" | ||
#include "arrayobject.h" | ||
#include "conversion_utils.h" | ||
#include "ctors.h" | ||
#include "methods.h" | ||
#include "descriptor.h" | ||
|
@@ -1624,7 +1625,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) | |
PyArray_Descr *descr = NULL; | ||
int itemsize; | ||
PyArray_Dims dims = {NULL, 0}; | ||
PyArray_Dims strides = {NULL, 0}; | ||
PyArray_Dims strides = {NULL, -1}; | ||
PyArray_Chunk buffer; | ||
npy_longlong offset = 0; | ||
NPY_ORDER order = NPY_CORDER; | ||
|
@@ -1645,7 +1646,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) | |
PyArray_BufferConverter, | ||
&buffer, | ||
&offset, | ||
&PyArray_IntpConverter, | ||
&PyArray_OptionalIntpConverter, | ||
&strides, | ||
&PyArray_OrderConverter, | ||
&order)) { | ||
|
@@ -1660,7 +1661,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) | |
|
||
itemsize = descr->elsize; | ||
|
||
if (strides.ptr != NULL) { | ||
if (strides.len != -1) { | ||
npy_intp nb, off; | ||
if (strides.len != dims.len) { | ||
PyErr_SetString(PyExc_ValueError, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters