summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2018-03-12 22:47:12 +0000
committerNathaniel J. Smith <njs@pobox.com>2018-03-12 15:47:12 -0700
commite97de95d4cae6805ed6c258655e7492a5f2ce863 (patch)
treeffea6426cc80a5f6f8f77a73b219ef3aac840c15 /numpy/lib
parent5324067c702a41e901354a01a5f0d05ff49b6cb4 (diff)
downloadnumpy-e97de95d4cae6805ed6c258655e7492a5f2ce863.tar.gz
Fix low-hanging Pypy compatibility issues (#10737)
* TST: skip refcount-requiring tests if sys.refcount is missing * ENH: io: add refcheck=False to a safe .resize() call The array is allocated immediately above, and the resize always succeeds so it is not necessary to check it. Fixes Pypy compatibility. * TST: remove unused code * TST: factor skipif(not HAS_REFCOUNT) into a separate decorator
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/npyio.py2
-rw-r--r--numpy/lib/tests/test_function_base.py4
-rw-r--r--numpy/lib/tests/test_io.py3
3 files changed, 5 insertions, 4 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 959574594..0f338d781 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1104,7 +1104,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
nshape = list(X.shape)
pos = nshape[0]
nshape[0] += len(x)
- X.resize(nshape)
+ X.resize(nshape, refcheck=False)
X[pos:, ...] = x
finally:
if fown:
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 49b450175..2b1ac1cc0 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -11,7 +11,7 @@ from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_array_equal,
assert_almost_equal, assert_array_almost_equal, assert_raises,
assert_allclose, assert_array_max_ulp, assert_warns, assert_raises_regex,
- dec, suppress_warnings, HAS_REFCOUNT,
+ dec, suppress_warnings,
)
import numpy.lib.function_base as nfb
from numpy.random import rand
@@ -2141,7 +2141,7 @@ class TestBincount(object):
"must not be negative",
lambda: np.bincount(x, minlength=-1))
- @dec.skipif(not HAS_REFCOUNT, "python has no sys.getrefcount")
+ @dec._needs_refcount
def test_dtype_reference_leaks(self):
# gh-6805
intp_refcount = sys.getrefcount(np.dtype(np.intp))
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index ae40cf73b..a0f256726 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -22,7 +22,7 @@ from numpy.ma.testutils import assert_equal
from numpy.testing import (
run_module_suite, assert_warns, assert_, SkipTest,
assert_raises_regex, assert_raises, assert_allclose,
- assert_array_equal, temppath, tempdir, dec, IS_PYPY, suppress_warnings
+ assert_array_equal, temppath, tempdir, dec, IS_PYPY, suppress_warnings,
)
@@ -2364,6 +2364,7 @@ def test_npzfile_dict():
assert_('x' in z.keys())
+@dec._needs_refcount
def test_load_refcount():
# Check that objects returned by np.load are directly freed based on
# their refcount, rather than needing the gc to collect them.