diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/arrayobject.c | 2 | ||||
-rw-r--r-- | numpy/core/src/multiarraymodule.c | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 76be69702..cfca0242e 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -5739,7 +5739,7 @@ PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) /* Cast to the desired type if we can do it safely Also cast if source is a ndim-0 array to mimic behavior with Python scalars */ - if (flags & FORCECAST || PyArray_NDIM(arr)==0 || + if ((flags & FORCECAST) || PyArray_NDIM(arr)==0 || PyArray_CanCastTo(oldtype, newtype)) { if ((flags & UPDATEIFCOPY) && \ (!PyArray_ISWRITEABLE(arr))) { diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index 6fb83c866..9bba689a2 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -2898,8 +2898,9 @@ PyArray_Put(PyArrayObject *self, PyObject* values0, PyObject *indices0) ni = PyArray_SIZE(indices); thistype = self->descr->type_num; - values = (PyArrayObject *)\ - PyArray_ContiguousFromAny(values0, thistype, 0, 0); + Py_INCREF(self->descr); + values = (PyArrayObject *)PyArray_FromAny(values0, self->descr, 0, 0, + DEFAULT_FLAGS | FORCECAST, NULL); if (values == NULL) goto fail; nv = PyArray_SIZE(values); if (nv > 0) { /* nv == 0 for a null array */ |