summaryrefslogtreecommitdiff
path: root/numpy/ma/tests/test_extras.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma/tests/test_extras.py')
-rw-r--r--numpy/ma/tests/test_extras.py52
1 files changed, 23 insertions, 29 deletions
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
index 33c4b1922..6d56d4dc6 100644
--- a/numpy/ma/tests/test_extras.py
+++ b/numpy/ma/tests/test_extras.py
@@ -13,7 +13,7 @@ import warnings
import numpy as np
from numpy.testing import (
- TestCase, run_module_suite, assert_warns, clear_and_catch_warnings
+ TestCase, run_module_suite, assert_warns, suppress_warnings
)
from numpy.ma.testutils import (
assert_, assert_array_equal, assert_equal, assert_almost_equal
@@ -764,7 +764,7 @@ class TestCov(TestCase):
def setUp(self):
self.data = array(np.random.rand(12))
- def test_1d_wo_missing(self):
+ def test_1d_without_missing(self):
# Test cov on 1D variable w/o missing values
x = self.data
assert_almost_equal(np.cov(x), cov(x))
@@ -772,7 +772,7 @@ class TestCov(TestCase):
assert_almost_equal(np.cov(x, rowvar=False, bias=True),
cov(x, rowvar=False, bias=True))
- def test_2d_wo_missing(self):
+ def test_2d_without_missing(self):
# Test cov on 1 2D variable w/o missing values
x = self.data.reshape(3, 4)
assert_almost_equal(np.cov(x), cov(x))
@@ -780,7 +780,7 @@ class TestCov(TestCase):
assert_almost_equal(np.cov(x, rowvar=False, bias=True),
cov(x, rowvar=False, bias=True))
- def test_1d_w_missing(self):
+ def test_1d_with_missing(self):
# Test cov 1 1D variable w/missing values
x = self.data
x[-1] = masked
@@ -804,7 +804,7 @@ class TestCov(TestCase):
assert_almost_equal(np.cov(nx, nx[::-1], rowvar=False, bias=True),
cov(x, x[::-1], rowvar=False, bias=True))
- def test_2d_w_missing(self):
+ def test_2d_with_missing(self):
# Test cov on 2D variable w/ missing value
x = self.data
x[-1] = masked
@@ -826,12 +826,6 @@ class TestCov(TestCase):
x.shape[0] / frac))
-class catch_warn_mae(clear_and_catch_warnings):
- """ Context manager to catch, reset warnings in ma.extras module
- """
- class_modules = (mae,)
-
-
class TestCorrcoef(TestCase):
def setUp(self):
@@ -843,10 +837,10 @@ class TestCorrcoef(TestCase):
x, y = self.data, self.data2
expected = np.corrcoef(x)
expected2 = np.corrcoef(x, y)
- with catch_warn_mae():
+ with suppress_warnings() as sup:
warnings.simplefilter("always")
assert_warns(DeprecationWarning, corrcoef, x, ddof=-1)
- warnings.simplefilter("ignore")
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
# ddof has no or negligible effect on the function
assert_almost_equal(np.corrcoef(x, ddof=0), corrcoef(x, ddof=0))
assert_almost_equal(corrcoef(x, ddof=-1), expected)
@@ -858,38 +852,38 @@ class TestCorrcoef(TestCase):
x, y = self.data, self.data2
expected = np.corrcoef(x)
# bias raises DeprecationWarning
- with catch_warn_mae():
+ with suppress_warnings() as sup:
warnings.simplefilter("always")
assert_warns(DeprecationWarning, corrcoef, x, y, True, False)
assert_warns(DeprecationWarning, corrcoef, x, y, True, True)
assert_warns(DeprecationWarning, corrcoef, x, bias=False)
- warnings.simplefilter("ignore")
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
# bias has no or negligible effect on the function
assert_almost_equal(corrcoef(x, bias=1), expected)
- def test_1d_wo_missing(self):
+ def test_1d_without_missing(self):
# Test cov on 1D variable w/o missing values
x = self.data
assert_almost_equal(np.corrcoef(x), corrcoef(x))
assert_almost_equal(np.corrcoef(x, rowvar=False),
corrcoef(x, rowvar=False))
- with catch_warn_mae():
- warnings.simplefilter("ignore")
+ with suppress_warnings() as sup:
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
assert_almost_equal(np.corrcoef(x, rowvar=False, bias=True),
corrcoef(x, rowvar=False, bias=True))
- def test_2d_wo_missing(self):
+ def test_2d_without_missing(self):
# Test corrcoef on 1 2D variable w/o missing values
x = self.data.reshape(3, 4)
assert_almost_equal(np.corrcoef(x), corrcoef(x))
assert_almost_equal(np.corrcoef(x, rowvar=False),
corrcoef(x, rowvar=False))
- with catch_warn_mae():
- warnings.simplefilter("ignore")
+ with suppress_warnings() as sup:
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
assert_almost_equal(np.corrcoef(x, rowvar=False, bias=True),
corrcoef(x, rowvar=False, bias=True))
- def test_1d_w_missing(self):
+ def test_1d_with_missing(self):
# Test corrcoef 1 1D variable w/missing values
x = self.data
x[-1] = masked
@@ -898,8 +892,8 @@ class TestCorrcoef(TestCase):
assert_almost_equal(np.corrcoef(nx), corrcoef(x))
assert_almost_equal(np.corrcoef(nx, rowvar=False),
corrcoef(x, rowvar=False))
- with catch_warn_mae():
- warnings.simplefilter("ignore")
+ with suppress_warnings() as sup:
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
assert_almost_equal(np.corrcoef(nx, rowvar=False, bias=True),
corrcoef(x, rowvar=False, bias=True))
try:
@@ -911,15 +905,15 @@ class TestCorrcoef(TestCase):
assert_almost_equal(np.corrcoef(nx, nx[::-1]), corrcoef(x, x[::-1]))
assert_almost_equal(np.corrcoef(nx, nx[::-1], rowvar=False),
corrcoef(x, x[::-1], rowvar=False))
- with catch_warn_mae():
- warnings.simplefilter("ignore")
+ with suppress_warnings() as sup:
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
# ddof and bias have no or negligible effect on the function
assert_almost_equal(np.corrcoef(nx, nx[::-1]),
corrcoef(x, x[::-1], bias=1))
assert_almost_equal(np.corrcoef(nx, nx[::-1]),
corrcoef(x, x[::-1], ddof=2))
- def test_2d_w_missing(self):
+ def test_2d_with_missing(self):
# Test corrcoef on 2D variable w/ missing value
x = self.data
x[-1] = masked
@@ -928,8 +922,8 @@ class TestCorrcoef(TestCase):
test = corrcoef(x)
control = np.corrcoef(x)
assert_almost_equal(test[:-1, :-1], control[:-1, :-1])
- with catch_warn_mae():
- warnings.simplefilter("ignore")
+ with suppress_warnings() as sup:
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
# ddof and bias have no or negligible effect on the function
assert_almost_equal(corrcoef(x, ddof=-2)[:-1, :-1],
control[:-1, :-1])