summaryrefslogtreecommitdiff
path: root/numpy/core/src/multiarray
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2023-01-11 17:58:24 -0500
committerGitHub <noreply@github.com>2023-01-11 17:58:24 -0500
commitbb2769e12a8646f3d63097e9464592aa6e20058d (patch)
tree353eab32241b60b5f916f4cdb8eebbe270bae6a4 /numpy/core/src/multiarray
parent77253908b0b9e4c296b9ff3c7733566eaa760e36 (diff)
parent9e98e33417621171dc84bdaafbb1b337b8bd92bd (diff)
downloadnumpy-bb2769e12a8646f3d63097e9464592aa6e20058d.tar.gz
Merge pull request #22998 from seberg/dep-positive-finalize
DEP: Finalize `+arr` returning a copy e.g. for string arrays
Diffstat (limited to 'numpy/core/src/multiarray')
-rw-r--r--numpy/core/src/multiarray/number.c41
1 files changed, 2 insertions, 39 deletions
diff --git a/numpy/core/src/multiarray/number.c b/numpy/core/src/multiarray/number.c
index df814a796..2e25152d5 100644
--- a/numpy/core/src/multiarray/number.c
+++ b/numpy/core/src/multiarray/number.c
@@ -539,47 +539,10 @@ array_power(PyObject *a1, PyObject *o2, PyObject *modulo)
static PyObject *
array_positive(PyArrayObject *m1)
{
- /*
- * For backwards compatibility, where + just implied a copy,
- * we cannot just call n_ops.positive. Instead, we do the following
- * 1. Try n_ops.positive
- * 2. If we get an exception, check whether __array_ufunc__ is
- * overridden; if so, we live in the future and we allow the
- * TypeError to be passed on.
- * 3. If not, give a deprecation warning and return a copy.
- */
- PyObject *value;
if (can_elide_temp_unary(m1)) {
- value = PyArray_GenericInplaceUnaryFunction(m1, n_ops.positive);
+ return PyArray_GenericInplaceUnaryFunction(m1, n_ops.positive);
}
- else {
- value = PyArray_GenericUnaryFunction(m1, n_ops.positive);
- }
- if (value == NULL) {
- /*
- * We first fetch the error, as it needs to be clear to check
- * for the override. When the deprecation is removed,
- * this whole stanza can be deleted.
- */
- PyObject *exc, *val, *tb;
- PyErr_Fetch(&exc, &val, &tb);
- if (PyUFunc_HasOverride((PyObject *)m1)) {
- PyErr_Restore(exc, val, tb);
- return NULL;
- }
- Py_XDECREF(exc);
- Py_XDECREF(val);
- Py_XDECREF(tb);
-
- /* 2018-06-28, 1.16.0 */
- if (DEPRECATE("Applying '+' to a non-numerical array is "
- "ill-defined. Returning a copy, but in the future "
- "this will error.") < 0) {
- return NULL;
- }
- value = PyArray_Return((PyArrayObject *)PyArray_Copy(m1));
- }
- return value;
+ return PyArray_GenericUnaryFunction(m1, n_ops.positive);
}
static PyObject *