From e828f1569dd65cb8a93a619fc89edec582c744cc Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Tue, 8 Jun 2021 14:56:41 +0530 Subject: Add tests for scalars --- numpy/core/src/multiarray/ctors.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'numpy/core/src') diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 87406bdbc..c2abc299c 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -1715,6 +1715,12 @@ PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth, /* Create a new array and copy the data */ Py_INCREF(dtype); /* hold on in case of a subarray that is replaced */ + if( flags & NPY_ARRAY_ENSURENOCOPY ) { + PyErr_SetString(PyExc_ValueError, + "Unable to avoid copy while creating " + "an array from descriptor."); + return NULL; + } ret = (PyArrayObject *)PyArray_NewFromDescr( &PyArray_Type, dtype, ndim, dims, NULL, NULL, flags&NPY_ARRAY_F_CONTIGUOUS, NULL); @@ -1839,6 +1845,7 @@ PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth, if (obj == NULL) { return NULL; } + if ((requires & NPY_ARRAY_ELEMENTSTRIDES) && !PyArray_ElementStrides(obj)) { PyObject *ret; -- cgit v1.2.1