summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorSebastian Berg <sebastianb@nvidia.com>2023-01-11 22:19:30 +0100
committerSebastian Berg <sebastianb@nvidia.com>2023-01-11 22:24:10 +0100
commit9e98e33417621171dc84bdaafbb1b337b8bd92bd (patch)
tree419ad4c78dba4a8f59c550b8cfb6af61718962eb /numpy/core/src
parent55e47e36ec9dbdd47d58900a8b504d9e159f1beb (diff)
downloadnumpy-9e98e33417621171dc84bdaafbb1b337b8bd92bd.tar.gz
DEP: Finalize `+arr` returning a copy e.g. for string arrays
This was deprecated 4-5 years ago in NumPy 1.16. Pandas stumbled over it cleaning up their warning filters, so I decided to just expire it.
Diffstat (limited to 'numpy/core/src')
-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 *