From 6bf0e419dc79ea6815557c57b7e9bb504ba20543 Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Thu, 7 May 2015 22:57:16 -0700 Subject: MAINT: Remove NotImplemented handling from ufuncs (almost) This was redundant/broken anyway. See gh-5844 for discussion. See the massive comment added to ufunc_object.c:get_ufunc_arguments for a discussion of the deprecation strategy here -- it turns out that array_richcompare is such a disaster zone that we can't quite wholly eliminate NotImplemented quite yet. But this removes most NotImplementeds, and lays the groundwork for eliminating the rest in a release or two. --- doc/release/1.10.0-notes.rst | 47 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst index cb78b4e71..50b1aa0b8 100644 --- a/doc/release/1.10.0-notes.rst +++ b/doc/release/1.10.0-notes.rst @@ -20,19 +20,23 @@ Highlights * Addition of `nanprod` to the set of nanfunctions. * Support for the '@' operator in Python 3.5. +Dropped Support: -Dropped Support -=============== * The polytemplate.py file has been removed. * The _dotblas module is no longer available. * The testcalcs.py file has been removed. +Future Changes: -Future Changes -============== +* In array comparisons like ``arr1 == arr2``, many corner cases + involving strings or structured dtypes that used to return scalars + now issue ``FutureWarning`` or ``DeprecationWarning``, and in the + future will be change to either perform elementwise comparisons or + raise an error. * The SafeEval class will be removed. * The alterdot and restoredot functions will be removed. +See below for more details on these changes. Compatibility notes =================== @@ -277,6 +281,41 @@ array is writeable. Deprecations ============ +Array comparisons involving strings or structured dtypes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Normally, comparison operations on arrays perform elementwise +comparisons and return arrays of booleans. But in some corner cases, +especially involving strings are structured dtypes, NumPy has +historically returned a scalar instead. For example:: + + ### Current behaviour + + np.arange(2) == "foo" + # -> False + + np.arange(2) < "foo" + # -> True on Python 2, error on Python 3 + + np.ones(2, dtype="i4,i4") == np.ones(2, dtype="i4,i4,i4") + # -> False + +Continuing work started in 1.9, in 1.10 these comparisons will now +raise ``FutureWarning`` or ``DeprecationWarning``, and in the future +they will be modified to behave more consistently with other +comparison operations, e.g.:: + + ### Future behaviour + + np.arange(2) == "foo" + # -> array([False, False]) + + np.arange(2) < "foo" + # -> error, strings and numbers are not orderable + + np.ones(2, dtype="i4,i4") == np.ones(2, dtype="i4,i4,i4") + # -> [False, False] + SafeEval ~~~~~~~~ The SafeEval class in numpy/lib/utils.py is deprecated and will be removed -- cgit v1.2.1