From 9ef5f37397051104835b2de4ae9c5de2b824be26 Mon Sep 17 00:00:00 2001 From: Seth Troisi Date: Thu, 23 Jan 2020 17:25:52 -0800 Subject: [PATCH] MAINT: Python2 Cleanups --- numpy/core/src/multiarray/arrayobject.c | 8 +++----- numpy/core/src/multiarray/typeinfo.c | 4 +++- numpy/linalg/lapack_lite/README.rst | 2 +- numpy/linalg/linalg.py | 7 ------- tools/refguide_check.py | 6 ------ 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c index aef0db36c269..86129104a5a9 100644 --- a/numpy/core/src/multiarray/arrayobject.c +++ b/numpy/core/src/multiarray/arrayobject.c @@ -1329,9 +1329,8 @@ _failed_comparison_workaround(PyArrayObject *self, PyObject *other, int cmp_op) /* * For LE, LT, GT, GE and a flexible self or other, we return * NotImplemented, which is the correct answer since the ufuncs do - * not in fact implement loops for those. On python 3 this will - * get us the desired TypeError, but on python 2, one gets strange - * ordering, so we emit a warning. + * not in fact implement loops for those. This will get us the + * desired TypeError. */ Py_XDECREF(exc); Py_XDECREF(val); @@ -1539,8 +1538,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) * (MHvK, 2018-06-18: not sure about this, but it's what we have). * * However, for backwards compatibility, we cannot yet return arrays, - * so we raise warnings instead. Furthermore, we warn on python2 - * for LT, LE, GE, GT, since fall-back behaviour is poorly defined. + * so we raise warnings instead. */ result = _failed_comparison_workaround(self, other, cmp_op); } diff --git a/numpy/core/src/multiarray/typeinfo.c b/numpy/core/src/multiarray/typeinfo.c index 30053887bda6..b0563b3c0ef8 100644 --- a/numpy/core/src/multiarray/typeinfo.c +++ b/numpy/core/src/multiarray/typeinfo.c @@ -5,8 +5,10 @@ */ #include "typeinfo.h" -/* In python 2, this is not exported from Python.h */ +#if (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM <= 0x07030000)) +/* PyPy issue 3160 */ #include +#endif #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE diff --git a/numpy/linalg/lapack_lite/README.rst b/numpy/linalg/lapack_lite/README.rst index ba30aa4ed5b9..ed738ab86d75 100644 --- a/numpy/linalg/lapack_lite/README.rst +++ b/numpy/linalg/lapack_lite/README.rst @@ -20,7 +20,7 @@ The routines that ``lapack_litemodule.c`` wraps are listed in properly. Assuming that you have an unpacked LAPACK source tree in ``~/LAPACK``, you generate the new routines in this directory with:: -$ python2 ./make_lite.py wrapped_routines ~/LAPACK +$ python ./make_lite.py wrapped_routines ~/LAPACK This will grab the right routines, with dependencies, put them into the appropriate ``f2c_*.f`` files, run ``f2c`` over them, then do some scrubbing diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 7c0b6facf8bb..0964e807bcd6 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -37,13 +37,6 @@ overrides.array_function_dispatch, module='numpy.linalg') -# For Python2/3 compatibility -_N = b'N' -_V = b'V' -_A = b'A' -_S = b'S' -_L = b'L' - fortran_int = intc diff --git a/tools/refguide_check.py b/tools/refguide_check.py index ad3f93c42d8b..db02f2e3a512 100644 --- a/tools/refguide_check.py +++ b/tools/refguide_check.py @@ -656,7 +656,6 @@ class Checker(doctest.OutputChecker): Check the docstrings """ obj_pattern = re.compile('at 0x[0-9a-fA-F]+>') - int_pattern = re.compile('^[0-9]+L?$') vanilla = doctest.OutputChecker() rndm_markers = {'# random', '# Random', '#random', '#Random', "# may vary", "# uninitialized", "#uninitialized"} @@ -695,11 +694,6 @@ def check_output(self, want, got, optionflags): if want.lstrip().startswith("#"): return True - # python 2 long integers are equal to python 3 integers - if self.int_pattern.match(want) and self.int_pattern.match(got): - if want.rstrip("L\r\n") == got.rstrip("L\r\n"): - return True - # try the standard doctest try: if self.vanilla.check_output(want, got, optionflags):