summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test__iotools.py7
-rw-r--r--numpy/lib/tests/test_function_base.py41
-rw-r--r--numpy/lib/tests/test_io.py19
-rw-r--r--numpy/lib/tests/test_regression.py3
-rw-r--r--numpy/lib/tests/test_type_check.py2
5 files changed, 35 insertions, 37 deletions
diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py
index 1d69d869e..6964c1128 100644
--- a/numpy/lib/tests/test__iotools.py
+++ b/numpy/lib/tests/test__iotools.py
@@ -9,7 +9,6 @@ from numpy.lib._iotools import (
LineSplitter, NameValidator, StringConverter,
has_nested_fields, easy_dtype, flatten_dtype
)
-from numpy.compat import unicode
class TestLineSplitter:
@@ -179,10 +178,10 @@ class TestStringConverter:
# note that the longdouble type has been skipped, so the
# _status increases by 2. Everything should succeed with
# unicode conversion (5).
- for s in ['a', u'a', b'a']:
+ for s in ['a', b'a']:
res = converter.upgrade(s)
- assert_(type(res) is unicode)
- assert_equal(res, u'a')
+ assert_(type(res) is str)
+ assert_equal(res, 'a')
assert_equal(converter._status, 5 + status_offset)
def test_missing(self):
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 04b280038..23bf3296d 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -21,7 +21,6 @@ from numpy.lib import (
select, setxor1d, sinc, trapz, trim_zeros, unwrap, unique, vectorize
)
-from numpy.compat import long
def get_mat(n):
data = np.arange(n)
@@ -509,12 +508,11 @@ class TestInsert:
insert(a, 1, a[:, 2, :], axis=1))
def test_0d(self):
- # This is an error in the future
a = np.array(1)
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings('always', '', DeprecationWarning)
- assert_equal(insert(a, [], 2, axis=0), np.array(2))
- assert_(w[0].category is DeprecationWarning)
+ with pytest.raises(np.AxisError):
+ insert(a, [], 2, axis=0)
+ with pytest.raises(TypeError):
+ insert(a, [], 2, axis="nonsense")
def test_subclass(self):
class SubClass(np.ndarray):
@@ -810,9 +808,6 @@ class TestDelete:
a_del = delete(self.a, indices)
nd_a_del = delete(self.nd_a, indices, axis=1)
msg = 'Delete failed for obj: %r' % indices
- # NOTE: The cast should be removed after warning phase for bools
- if not isinstance(indices, (slice, int, long, np.integer)):
- indices = np.asarray(indices, dtype=np.intp)
assert_array_equal(setxor1d(a_del, self.a[indices, ]), self.a,
err_msg=msg)
xor = setxor1d(nd_a_del[0,:, 0], self.nd_a[0, indices, 0])
@@ -828,7 +823,6 @@ class TestDelete:
self._check_inverse_of_slicing(s)
def test_fancy(self):
- # Deprecation/FutureWarning tests should be kept after change.
self._check_inverse_of_slicing(np.array([[0, 1], [2, 1]]))
with pytest.raises(IndexError):
delete(self.a, [100])
@@ -837,14 +831,17 @@ class TestDelete:
self._check_inverse_of_slicing([0, -1, 2, 2])
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings('always', category=FutureWarning)
- obj = np.array([True, False, False], dtype=bool)
- self._check_inverse_of_slicing(obj)
- # _check_inverse_of_slicing operates on two arrays, so warns twice
- assert len(w) == 2
- assert_(w[0].category is FutureWarning)
- assert_(w[1].category is FutureWarning)
+ self._check_inverse_of_slicing([True, False, False, True, False])
+
+ # not legal, indexing with these would change the dimension
+ with pytest.raises(ValueError):
+ delete(self.a, True)
+ with pytest.raises(ValueError):
+ delete(self.a, False)
+
+ # not enough items
+ with pytest.raises(ValueError):
+ delete(self.a, [False]*4)
def test_single(self):
self._check_inverse_of_slicing(0)
@@ -852,10 +849,10 @@ class TestDelete:
def test_0d(self):
a = np.array(1)
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings('always', '', DeprecationWarning)
- assert_equal(delete(a, [], axis=0), a)
- assert_(w[0].category is DeprecationWarning)
+ with pytest.raises(np.AxisError):
+ delete(a, [], axis=0)
+ with pytest.raises(TypeError):
+ delete(a, [], axis="nonsense")
def test_subclass(self):
class SubClass(np.ndarray):
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 6812d8d68..8ce20a116 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -13,6 +13,7 @@ from tempfile import NamedTemporaryFile
from io import BytesIO, StringIO
from datetime import datetime
import locale
+from multiprocessing import Process
import numpy as np
import numpy.ma as ma
@@ -569,16 +570,20 @@ class TestSaveTxt:
assert_equal(s.read(), b"%f\n" % 1.)
@pytest.mark.skipif(sys.platform=='win32', reason="files>4GB may not work")
- @pytest.mark.skipif(IS_PYPY,
- reason="GC problems after test, gc.collect does not help. see gh-15775")
@pytest.mark.slow
@requires_memory(free_bytes=7e9)
def test_large_zip(self):
- # The test takes at least 6GB of memory, writes a file larger than 4GB
- test_data = np.asarray([np.random.rand(np.random.randint(50,100),4)
- for i in range(800000)], dtype=object)
- with tempdir() as tmpdir:
- np.savez(os.path.join(tmpdir, 'test.npz'), test_data=test_data)
+ def check_large_zip():
+ # The test takes at least 6GB of memory, writes a file larger than 4GB
+ test_data = np.asarray([np.random.rand(np.random.randint(50,100),4)
+ for i in range(800000)], dtype=object)
+ with tempdir() as tmpdir:
+ np.savez(os.path.join(tmpdir, 'test.npz'), test_data=test_data)
+ # run in a subprocess to ensure memory is released on PyPy, see gh-15775
+ p = Process(target=check_large_zip)
+ p.start()
+ p.join()
+ assert p.exitcode == 0
class LoadTxtBase:
def check_compressed(self, fopen, suffixes):
diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py
index a2598990b..55df2a675 100644
--- a/numpy/lib/tests/test_regression.py
+++ b/numpy/lib/tests/test_regression.py
@@ -5,7 +5,6 @@ from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
assert_raises, _assert_valid_refcount,
)
-from numpy.compat import unicode
class TestRegression:
@@ -180,7 +179,7 @@ class TestRegression:
# related to ticket #1405.
include_dirs = [np.get_include()]
for path in include_dirs:
- assert_(isinstance(path, (str, unicode)))
+ assert_(isinstance(path, str))
assert_(path != '')
def test_polyder_return_type(self):
diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py
index 47685550a..3f4ca6309 100644
--- a/numpy/lib/tests/test_type_check.py
+++ b/numpy/lib/tests/test_type_check.py
@@ -1,5 +1,4 @@
import numpy as np
-from numpy.compat import long
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_raises
)
@@ -86,7 +85,6 @@ class TestIsscalar:
assert_(not np.isscalar([3]))
assert_(not np.isscalar((3,)))
assert_(np.isscalar(3j))
- assert_(np.isscalar(long(10)))
assert_(np.isscalar(4.0))