summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/_internal.py8
-rw-r--r--numpy/core/tests/test_multiarray.py15
-rw-r--r--numpy/core/tests/test_numerictypes.py3
-rw-r--r--numpy/f2py/tests/test_block_docstring.py3
-rw-r--r--numpy/lib/tests/test_function_base.py3
5 files changed, 21 insertions, 11 deletions
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."