diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | azure-pipelines.yml | 8 | ||||
| -rw-r--r-- | numpy/core/_internal.py | 8 | ||||
| -rw-r--r-- | numpy/core/tests/test_multiarray.py | 15 | ||||
| -rw-r--r-- | numpy/core/tests/test_numerictypes.py | 3 | ||||
| -rw-r--r-- | numpy/f2py/tests/test_block_docstring.py | 3 | ||||
| -rw-r--r-- | numpy/lib/tests/test_function_base.py | 3 | ||||
| -rw-r--r-- | tools/azure-pypy-test.sh | 10 | ||||
| -rwxr-xr-x | tools/pypy-test.sh | 11 |
9 files changed, 37 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore index 1b90490ff..e706ad680 100644 --- a/.gitignore +++ b/.gitignore @@ -177,4 +177,4 @@ cythonize.dat numpy/random/mtrand/mtrand.c numpy/random/mtrand/randint_helpers.pxi # CI run of PyPy -pypy3.5-latest +pypy3 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3fe8704f0..31e548360 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -211,13 +211,13 @@ jobs: failTaskOnFailedTests: true testRunTitle: 'Publish test results for Python $(PYTHON_VERSION) $(BITS)-bit $(TEST_MODE) Windows' -- job: Linux_PyPy3_latest_nightly +- job: Linux_PyPy3 pool: vmIMage: 'ubuntu-16.04' steps: - - script: source tools/azure-pypy-test.sh - displayName: 'Run PyPy3.5 Build / Tests' + - script: source tools/pypy-test.sh + displayName: 'Run PyPy3 Build / Tests' - task: PublishTestResults@2 inputs: testResultsFiles: '**/test-*.xml' - testRunTitle: 'Publish test results for PyPy3.5' + testRunTitle: 'Publish test results for PyPy3' diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 82035e561..1100fbf0e 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -8,6 +8,7 @@ from __future__ import division, absolute_import, print_function import re import sys +import platform from numpy.compat import unicode from .multiarray import dtype, array, ndarray @@ -16,6 +17,8 @@ try: except ImportError: ctypes = None +IS_PYPY = platform.python_implementation() == 'PyPy' + if (sys.byteorder == 'little'): _nbo = b'<' else: @@ -865,7 +868,10 @@ def npy_ctypes_check(cls): try: # ctypes class are new-style, so have an __mro__. This probably fails # for ctypes classes with multiple inheritance. - ctype_base = cls.__mro__[-2] + if IS_PYPY: + ctype_base = cls.__mro__[-3] + else: + ctype_base = cls.__mro__[-2] # right now, they're part of the _ctypes module return 'ctypes' in ctype_base.__module__ except Exception: diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index c45029599..5bab992fa 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -131,6 +131,7 @@ class TestFlags(object): assert_(vals.flags.writeable) @pytest.mark.skipif(sys.version_info[0] < 3, reason="Python 2 always copies") + @pytest.mark.skipif(IS_PYPY, reason="PyPy always copies") def test_writeable_pickle(self): import pickle # Small arrays will be copied without setting base. @@ -3783,7 +3784,7 @@ class TestPickling(object): a, pickle.loads(pickle.dumps(a, protocol=proto)), err_msg="%r" % a) del a, DATA, carray - gc.collect() + gc.collect(); gc.collect(); gc.collect() # check for reference leaks (gh-12793) for ref in refs: assert ref() is None @@ -7180,7 +7181,7 @@ class TestMemEventHook(object): # needs to be larger then limit of small memory cacher in ctors.c a = np.zeros(1000) del a - gc.collect() + gc.collect(); gc.collect(); gc.collect() _multiarray_tests.test_pydatamem_seteventhook_end() class TestMapIter(object): @@ -7752,12 +7753,12 @@ class TestCTypes(object): # `ctypes_ptr` should hold onto `arr` del arr - gc.collect() + gc.collect(); gc.collect(); gc.collect() assert_(arr_ref() is not None, "ctypes pointer did not hold onto a reference") # but when the `ctypes_ptr` object dies, so should `arr` del ctypes_ptr - gc.collect() + gc.collect(); gc.collect(); gc.collect() assert_(arr_ref() is None, "unknowable whether ctypes pointer holds a reference") @@ -7939,15 +7940,15 @@ class TestArrayFinalize(object): assert_(isinstance(obj_subarray, RaisesInFinalize)) # reference should still be held by obj_arr - gc.collect() + gc.collect(); gc.collect(); gc.collect() assert_(obj_ref() is not None, "object should not already be dead") del obj_arr - gc.collect() + gc.collect(); gc.collect(); gc.collect() assert_(obj_ref() is not None, "obj_arr should not hold the last reference") del obj_subarray - gc.collect() + gc.collect(); gc.collect(); gc.collect() assert_(obj_ref() is None, "no references should remain") diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py index 71f7b7150..d0ff5578a 100644 --- a/numpy/core/tests/test_numerictypes.py +++ b/numpy/core/tests/test_numerictypes.py @@ -5,7 +5,7 @@ import itertools import pytest import numpy as np -from numpy.testing import assert_, assert_equal, assert_raises +from numpy.testing import assert_, assert_equal, assert_raises, IS_PYPY # This is the structure of the table used for plain objects: # @@ -491,6 +491,7 @@ def test_issctype(rep, expected): @pytest.mark.skipif(sys.flags.optimize > 1, reason="no docstrings present to inspect when PYTHONOPTIMIZE/Py_OptimizeFlag > 1") +@pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc") class TestDocStrings(object): def test_platform_dependent_aliases(self): if np.int64 is np.int_: diff --git a/numpy/f2py/tests/test_block_docstring.py b/numpy/f2py/tests/test_block_docstring.py index 8fc072a5e..4f1678980 100644 --- a/numpy/f2py/tests/test_block_docstring.py +++ b/numpy/f2py/tests/test_block_docstring.py @@ -4,7 +4,7 @@ import sys import pytest from . import util -from numpy.testing import assert_equal +from numpy.testing import assert_equal, IS_PYPY class TestBlockDocString(util.F2PyTest): code = """ @@ -18,6 +18,7 @@ class TestBlockDocString(util.F2PyTest): @pytest.mark.skipif(sys.platform=='win32', reason='Fails with MinGW64 Gfortran (Issue #9673)') + @pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc") def test_block_docstring(self): expected = "'i'-array(2,3)\n" assert_equal(self.module.block.__doc__, expected) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 1e04bfaec..e2c24a123 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -11,7 +11,7 @@ import numpy as np from numpy import ma from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_almost_equal, - assert_array_almost_equal, assert_raises, assert_allclose, + assert_array_almost_equal, assert_raises, assert_allclose, IS_PYPY, assert_warns, assert_raises_regex, suppress_warnings, HAS_REFCOUNT, ) import numpy.lib.function_base as nfb @@ -3177,6 +3177,7 @@ class TestAdd_newdoc_ufunc(object): class TestAdd_newdoc(object): @pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO") + @pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc") def test_add_doc(self): # test np.add_newdoc tgt = "Current flat index into the array." diff --git a/tools/azure-pypy-test.sh b/tools/azure-pypy-test.sh deleted file mode 100644 index 2194b724d..000000000 --- a/tools/azure-pypy-test.sh +++ /dev/null @@ -1,10 +0,0 @@ -wget http://buildbot.pypy.org/nightly/py3.5/pypy-c-jit-latest-linux64.tar.bz2 -O pypy.tar.bz2 -mkdir -p pypy3.5-latest -(cd pypy3.5-latest; tar --strip-components=1 -xf ../pypy.tar.bz2) -pypy3.5-latest/bin/pypy3 -mensurepip -pypy3.5-latest/bin/pypy3 -m pip install --upgrade pip setuptools -pypy3.5-latest/bin/pypy3 -m pip install --user cython==0.29.0 pytest pytz -pypy3.5-latest/bin/pypy3 runtests.py -- -rsx --junitxml=junit/test-results.xml --durations 10 -# do not fail the CI run -echo '' - diff --git a/tools/pypy-test.sh b/tools/pypy-test.sh new file mode 100755 index 000000000..bcadc1d6d --- /dev/null +++ b/tools/pypy-test.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +apt-get -yq update +apt-get -yq install libatlas-dev libatlas-base-dev liblapack-dev +wget http://buildbot.pypy.org/nightly/py3.6/pypy-c-jit-latest-linux64.tar.bz2 -O pypy.tar.bz2 +mkdir -p pypy3 +(cd pypy3; tar --strip-components=1 -xf ../pypy.tar.bz2) +pypy3/bin/pypy3 -mensurepip +pypy3/bin/pypy3 -m pip install --upgrade pip setuptools +pypy3/bin/pypy3 -m pip install --user cython==0.29.0 pytest pytz --no-warn-script-location +pypy3/bin/pypy3 runtests.py -- -rsx --junitxml=junit/test-results.xml --durations 10 |
