8000 MAINT: Cleanup references to python2 by sethtroisi · Pull Request #15417 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Cleanup references to python2 #15417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
8000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for PyPy3 numpy/core/src/multiarray/typeinfo.c:16:8: error: unknown type name ‘PyStructSequence_Field’

I'll investigate further.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted removing the include because it fails in PyPy.
I opened an issue on pypy to see if this should be fixed in the future but even if it does that won't be fixed for months.
https://bitbucket.org/pypy/pypy/issues/3160/structseqh-missing-from-pythonh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better "In PyPy <= 7.3.0", and you can drop the comment if you do

#if (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM <= 0x07030000))
/* PyPy issue 3160 */
#include <structseq.h>
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment updated.

Thanks for the informative comments in the PyPy issue (https://bitbucket.org/pypy/pypy/issues/3160/structseqh-missing-from-pythonh)

#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
``~/LAP 10000 ACK``, 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