diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/include/numpy/ndarraytypes.h | 3 | ||||
-rw-r--r-- | numpy/core/src/multiarray/calculation.c | 16 | ||||
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 12 |
3 files changed, 19 insertions, 12 deletions
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index 0e91a31df..374a9b622 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -204,6 +204,9 @@ typedef enum { NPY_UNSAFE_CASTING=4 } NPY_CASTING; +/* The default casting to use for typical assignment operations */ +#define NPY_DEFAULT_ASSIGN_CASTING NPY_SAME_KIND_CASTING + typedef enum { NPY_CLIP=0, NPY_WRAP=1, diff --git a/numpy/core/src/multiarray/calculation.c b/numpy/core/src/multiarray/calculation.c index b879d0981..9cc2b1509 100644 --- a/numpy/core/src/multiarray/calculation.c +++ b/numpy/core/src/multiarray/calculation.c @@ -408,7 +408,9 @@ __New_PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out, finish: if (out) { - if (PyArray_CopyAnyInto(out, (PyArrayObject *)ret) < 0) { + if (PyArray_AssignArray(out, (PyArrayObject *)ret, + NULL, NPY_DEFAULT_ASSIGN_CASTING, + 0, NULL) < 0) { Py_DECREF(ret); return NULL; } @@ -574,7 +576,9 @@ PyArray_Round(PyArrayObject *a, int decimals, PyArrayObject *out) if (decimals >= 0) { if (PyArray_ISINTEGER(a)) { if (out) { - if (PyArray_CopyAnyInto(out, a) < 0) { + if (PyArray_AssignArray(out, a, + NULL, NPY_DEFAULT_ASSIGN_CASTING, + 0, NULL) < 0) { return NULL; } Py_INCREF(out); @@ -1063,7 +1067,9 @@ PyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max, PyArrayObject *o goto fail; } if (PyArray_DATA(newout) != PyArray_DATA(newin)) { - if (PyArray_CopyInto(newout, newin) < 0) { + if (PyArray_AssignArray(newout, newin, + NULL, NPY_DEFAULT_ASSIGN_CASTING, + 0, NULL) < 0) { goto fail; } } @@ -1115,7 +1121,9 @@ PyArray_Conjugate(PyArrayObject *self, PyArrayObject *out) else { PyArrayObject *ret; if (out) { - if (PyArray_CopyAnyInto(out, self) < 0) { + if (PyArray_AssignArray(out, self, + NULL, NPY_DEFAULT_ASSIGN_CASTING, + 0, NULL) < 0) { return NULL; } ret = out; diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index aafae83ed..ee644569a 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -1769,10 +1769,8 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, PyObject *arr_prep_args = NULL; NPY_ORDER order = NPY_KEEPORDER; - /* - * Currently trying out SAME_KIND casting rule by default. - */ - NPY_CASTING casting = NPY_SAME_KIND_CASTING; + /* Use the default assignment casting rule */ + NPY_CASTING casting = NPY_DEFAULT_ASSIGN_CASTING; /* When provided, extobj and typetup contain borrowed references */ PyObject *extobj = NULL, *type_tup = NULL; @@ -2171,10 +2169,8 @@ PyUFunc_GenericFunction(PyUFuncObject *self, int trivial_loop_ok = 0, use_maskna = 0; NPY_ORDER order = NPY_KEEPORDER; - /* - * Currently trying out SAME_KIND casting rule by default. - */ - NPY_CASTING casting = NPY_SAME_KIND_CASTING; + /* Use the default assignment casting rule */ + NPY_CASTING casting = NPY_DEFAULT_ASSIGN_CASTING; /* When provided, extobj and typetup contain borrowed references */ PyObject *extobj = NULL, *type_tup = NULL; |