Skip to content

Commit

Permalink
MAINT: Python2 Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
sethtroisi committed Jan 29, 2020
1 parent 7b71975 commit 9ef5f37
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 20 deletions.
8 changes: 3 additions & 5 deletions numpy/core/src/multiarray/arrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion numpy/core/src/multiarray/typeinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <structseq.h>
#endif

#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#define _MULTIARRAYMODULE
Expand Down
2 changes: 1 addition & 1 deletion numpy/linalg/lapack_lite/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions numpy/linalg/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 0 additions & 6 deletions tools/refguide_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 9ef5f37

Please sign in to comment.