diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 20 | ||||
-rw-r--r-- | numpy/lib/tests/test_io.py | 15 |
2 files changed, 24 insertions, 11 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index fc033b164..a7d501c52 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -784,14 +784,18 @@ class TestHistogramdd(TestCase): def test_inf_edges(self): """Test using +/-inf bin edges works. See #1788.""" - x = np.arange(6).reshape(3, 2) - expected = np.array([[1, 0], [0, 1], [0, 1]]) - h, e = np.histogramdd(x, bins=[3, [-np.inf, 2, 10]]) - assert_allclose(h, expected) - h, e = np.histogramdd(x, bins=[3, np.array([-1, 2, np.inf])]) - assert_allclose(h, expected) - h, e = np.histogramdd(x, bins=[3, [-np.inf, 3, np.inf]]) - assert_allclose(h, expected) + olderr = np.seterr(invalid='ignore') + try: + x = np.arange(6).reshape(3, 2) + expected = np.array([[1, 0], [0, 1], [0, 1]]) + h, e = np.histogramdd(x, bins=[3, [-np.inf, 2, 10]]) + assert_allclose(h, expected) + h, e = np.histogramdd(x, bins=[3, np.array([-1, 2, np.inf])]) + assert_allclose(h, expected) + h, e = np.histogramdd(x, bins=[3, [-np.inf, 3, np.inf]]) + assert_allclose(h, expected) + finally: + np.seterr(**olderr) class TestUnique(TestCase): diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 949d8fb45..41a95de10 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -586,9 +586,18 @@ class TestLoadTxt(TestCase): e.seek(0) x = np.loadtxt(e, dtype=int, delimiter=',', ndmin=0) assert_(x.shape == (3,)) - f = StringIO() - assert_(np.loadtxt(f, ndmin=2).shape == (0, 1,)) - assert_(np.loadtxt(f, ndmin=1).shape == (0,)) + + # Test ndmin kw with empty file. + warn_ctx = WarningManager() + warn_ctx.__enter__() + try: + warnings.filterwarnings("ignore", + message="loadtxt: Empty input file:") + f = StringIO() + assert_(np.loadtxt(f, ndmin=2).shape == (0, 1,)) + assert_(np.loadtxt(f, ndmin=1).shape == (0,)) + finally: + warn_ctx.__exit__() def test_generator_source(self): def count(): |