summaryrefslogtreecommitdiff
path: root/numpy/ma/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r--numpy/ma/tests/test_core.py106
-rw-r--r--numpy/ma/tests/test_extras.py52
-rw-r--r--numpy/ma/tests/test_mrecords.py8
-rw-r--r--numpy/ma/tests/test_old_ma.py120
-rw-r--r--numpy/ma/tests/test_regression.py8
5 files changed, 156 insertions, 138 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index b3965000d..cbab5ad5b 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -19,13 +19,14 @@ import numpy as np
import numpy.ma.core
import numpy.core.fromnumeric as fromnumeric
import numpy.core.umath as umath
-from numpy.testing import TestCase, run_module_suite, assert_raises
+from numpy.testing import (
+ TestCase, run_module_suite, assert_raises, suppress_warnings)
from numpy import ndarray
from numpy.compat import asbytes, asbytes_nested
from numpy.ma.testutils import (
assert_, assert_array_equal, assert_equal, assert_almost_equal,
assert_equal_records, fail_if_equal, assert_not_equal,
- assert_mask_equal,
+ assert_mask_equal
)
from numpy.ma.core import (
MAError, MaskError, MaskType, MaskedArray, abs, absolute, add, all,
@@ -48,6 +49,12 @@ from numpy.ma.core import (
pi = np.pi
+suppress_copy_mask_on_assignment = suppress_warnings()
+suppress_copy_mask_on_assignment.filter(
+ numpy.ma.core.MaskedArrayFutureWarning,
+ "setting an item on a masked array which has a shared mask will not copy")
+
+
class TestMaskedArray(TestCase):
# Base test class for MaskedArrays.
@@ -366,6 +373,7 @@ class TestMaskedArray(TestCase):
assert_(allequal(array([0, 0, 0, 1, 0], MaskType), x2.mask))
assert_equal(3.0, x2.fill_value)
+ @suppress_copy_mask_on_assignment
def test_copy(self):
# Tests of some subtle points of copying and sizing.
n = [0, 0, 1, 0, 0]
@@ -524,14 +532,14 @@ class TestMaskedArray(TestCase):
assert_equal(1.0, float(array([[1]])))
self.assertRaises(TypeError, float, array([1, 1]))
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', UserWarning)
+ with suppress_warnings() as sup:
+ sup.filter(UserWarning, 'Warning: converting a masked element')
assert_(np.isnan(float(array([1], mask=[1]))))
- a = array([1, 2, 3], mask=[1, 0, 0])
- self.assertRaises(TypeError, lambda:float(a))
- assert_equal(float(a[-1]), 3.)
- self.assertTrue(np.isnan(float(a[0])))
+ a = array([1, 2, 3], mask=[1, 0, 0])
+ self.assertRaises(TypeError, lambda: float(a))
+ assert_equal(float(a[-1]), 3.)
+ self.assertTrue(np.isnan(float(a[0])))
self.assertRaises(TypeError, int, a)
assert_equal(int(a[-1]), 3)
self.assertRaises(MAError, lambda:int(a[0]))
@@ -578,6 +586,7 @@ class TestMaskedArray(TestCase):
assert_(z[1] is not masked)
assert_(z[2] is masked)
+ @suppress_copy_mask_on_assignment
def test_oddfeatures_3(self):
# Tests some generic features
atest = array([10], mask=True)
@@ -586,11 +595,11 @@ class TestMaskedArray(TestCase):
atest[idx] = btest[idx]
assert_equal(atest, [20])
- def test_filled_w_object_dtype(self):
+ def test_filled_with_object_dtype(self):
a = np.ma.masked_all(1, dtype='O')
assert_equal(a.filled('x')[0], 'x')
- def test_filled_w_flexible_dtype(self):
+ def test_filled_with_flexible_dtype(self):
# Test filled w/ flexible dtype
flexi = array([(1, 1, 1)],
dtype=[('i', int), ('s', '|S8'), ('f', float)])
@@ -603,7 +612,7 @@ class TestMaskedArray(TestCase):
assert_equal(flexi.filled(1),
np.array([(1, '1', 1.)], dtype=flexi.dtype))
- def test_filled_w_mvoid(self):
+ def test_filled_with_mvoid(self):
# Test filled w/ mvoid
ndtype = [('a', int), ('b', float)]
a = mvoid((1, 2.), mask=[(0, 1)], dtype=ndtype)
@@ -617,7 +626,7 @@ class TestMaskedArray(TestCase):
a.fill_value = (-999, -999)
assert_equal(tuple(a.filled()), (1, -999))
- def test_filled_w_nested_dtype(self):
+ def test_filled_with_nested_dtype(self):
# Test filled w/ nested dtype
ndtype = [('A', int), ('B', [('BA', int), ('BB', int)])]
a = array([(1, (1, 1)), (2, (2, 2))],
@@ -637,7 +646,7 @@ class TestMaskedArray(TestCase):
assert_equal(Z.mask.dtype, numpy.dtype([('A', [('f0', '?', (2, 2)),
('f1', '?', (2, 2))], (2, 2))]))
- def test_filled_w_f_order(self):
+ def test_filled_with_f_order(self):
# Test filled w/ F-contiguous array
a = array(np.array([(0, 1, 2), (4, 5, 6)], order='F'),
mask=np.array([(0, 0, 1), (1, 0, 0)], order='F'),
@@ -1332,29 +1341,33 @@ class TestMaskedArrayArithmetic(TestCase):
assert_equal(test, [False, True])
assert_equal(test.mask, [False, False])
- def test_eq_w_None(self):
+ def test_eq_with_None(self):
# Really, comparisons with None should not be done, but check them
# anyway. Note that pep8 will flag these tests.
+ # Deprecation is in place for arrays, and when it happens this
+ # test will fail (and have to be changed accordingly).
# With partial mask
- a = array([1, 2], mask=[0, 1])
- assert_equal(a == None, False)
- assert_equal(a.data == None, False)
- assert_equal(a.mask == None, False)
- assert_equal(a != None, True)
- # With nomask
- a = array([1, 2], mask=False)
- assert_equal(a == None, False)
- assert_equal(a != None, True)
- # With complete mask
- a = array([1, 2], mask=True)
- assert_equal(a == None, False)
- assert_equal(a != None, True)
- # Fully masked, even comparison to None should return "masked"
- a = masked
- assert_equal(a == None, masked)
-
- def test_eq_w_scalar(self):
+ with suppress_warnings() as sup:
+ sup.filter(FutureWarning, "Comparison to `None`")
+ a = array([1, 2], mask=[0, 1])
+ assert_equal(a == None, False)
+ assert_equal(a.data == None, False)
+ assert_equal(a.mask == None, False)
+ assert_equal(a != None, True)
+ # With nomask
+ a = array([1, 2], mask=False)
+ assert_equal(a == None, False)
+ assert_equal(a != None, True)
+ # With complete mask
+ a = array([1, 2], mask=True)
+ assert_equal(a == None, False)
+ assert_equal(a != None, True)
+ # Fully masked, even comparison to None should return "masked"
+ a = masked
+ assert_equal(a == None, masked)
+
+ def test_eq_with_scalar(self):
a = array(1)
assert_equal(a == 1, True)
assert_equal(a == 0, False)
@@ -2416,8 +2429,9 @@ class TestMaskedArrayInPlaceArithmetics(TestCase):
def test_inplace_division_scalar_type(self):
# Test of inplace division
for t in self.othertypes:
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings("always")
+ with suppress_warnings() as sup:
+ sup.record(UserWarning)
+
(x, y, xm) = (_.astype(t) for _ in self.uint8data)
x = arange(10, dtype=t) * t(2)
xm = arange(10, dtype=t) * t(2)
@@ -2444,15 +2458,15 @@ class TestMaskedArrayInPlaceArithmetics(TestCase):
warnings.warn(str(e))
if issubclass(t, np.integer):
- assert_equal(len(w), 2, "Failed on type=%s." % t)
+ assert_equal(len(sup.log), 2, "Failed on type=%s." % t)
else:
- assert_equal(len(w), 0, "Failed on type=%s." % t)
+ assert_equal(len(sup.log), 0, "Failed on type=%s." % t)
def test_inplace_division_array_type(self):
# Test of inplace division
for t in self.othertypes:
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings("always")
+ with suppress_warnings() as sup:
+ sup.record(UserWarning)
(x, y, xm) = (_.astype(t) for _ in self.uint8data)
m = xm.mask
a = arange(10, dtype=t)
@@ -2483,9 +2497,9 @@ class TestMaskedArrayInPlaceArithmetics(TestCase):
warnings.warn(str(e))
if issubclass(t, np.integer):
- assert_equal(len(w), 2, "Failed on type=%s." % t)
+ assert_equal(len(sup.log), 2, "Failed on type=%s." % t)
else:
- assert_equal(len(w), 0, "Failed on type=%s." % t)
+ assert_equal(len(sup.log), 0, "Failed on type=%s." % t)
def test_inplace_pow_type(self):
# Test keeping data w/ (inplace) power
@@ -2762,6 +2776,7 @@ class TestMaskedArrayMethods(TestCase):
b = a.view(masked_array)
assert_(np.may_share_memory(a.mask, b.mask))
+ @suppress_copy_mask_on_assignment
def test_put(self):
# Tests put.
d = arange(5)
@@ -3347,6 +3362,7 @@ class TestMaskedArrayMathMethods(TestCase):
assert_almost_equal(np.sqrt(mXvar0[k]),
mX[:, k].compressed().std())
+ @suppress_copy_mask_on_assignment
def test_varstd_specialcases(self):
# Test a special case for var
nout = np.array(-1, dtype=float)
@@ -3359,15 +3375,11 @@ class TestMaskedArrayMathMethods(TestCase):
self.assertTrue(method(0) is masked)
self.assertTrue(method(-1) is masked)
# Using a masked array as explicit output
- with warnings.catch_warnings():
- warnings.simplefilter('ignore')
- method(out=mout)
+ method(out=mout)
self.assertTrue(mout is not masked)
assert_equal(mout.mask, True)
# Using a ndarray as explicit output
- with warnings.catch_warnings():
- warnings.simplefilter('ignore')
- method(out=nout)
+ method(out=nout)
self.assertTrue(np.isnan(nout))
x = array(arange(10), mask=True)
@@ -3670,7 +3682,7 @@ class TestMaskedArrayFunctions(TestCase):
assert_almost_equal(x, y)
assert_almost_equal(x._data, y._data)
- def test_power_w_broadcasting(self):
+ def test_power_with_broadcasting(self):
# Test power w/ broadcasting
a2 = np.array([[1., 2., 3.], [4., 5., 6.]])
a2m = array(a2, mask=[[1, 0, 0], [0, 0, 1]])
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])
diff --git a/numpy/ma/tests/test_mrecords.py b/numpy/ma/tests/test_mrecords.py
index e97f337f5..ea5d14de0 100644
--- a/numpy/ma/tests/test_mrecords.py
+++ b/numpy/ma/tests/test_mrecords.py
@@ -148,11 +148,9 @@ class TestMRecords(TestCase):
rdata = data.view(MaskedRecords)
val = ma.array([10, 20, 30], mask=[1, 0, 0])
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- rdata['num'] = val
- assert_equal(rdata.num, val)
- assert_equal(rdata.num.mask, [1, 0, 0])
+ rdata['num'] = val
+ assert_equal(rdata.num, val)
+ assert_equal(rdata.num.mask, [1, 0, 0])
def test_set_fields_mask(self):
# Tests setting the mask of a field.
diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py
index ed8304d63..2ea53683d 100644
--- a/numpy/ma/tests/test_old_ma.py
+++ b/numpy/ma/tests/test_old_ma.py
@@ -5,7 +5,8 @@ from functools import reduce
import numpy as np
import numpy.core.umath as umath
import numpy.core.fromnumeric as fromnumeric
-from numpy.testing import TestCase, run_module_suite, assert_
+from numpy.testing import (
+ TestCase, run_module_suite, assert_, suppress_warnings)
from numpy.ma.testutils import assert_array_equal
from numpy.ma import (
MaskType, MaskedArray, absolute, add, all, allclose, allequal, alltrue,
@@ -257,62 +258,73 @@ class TestMa(TestCase):
def test_testCopySize(self):
# Tests of some subtle points of copying and sizing.
- n = [0, 0, 1, 0, 0]
- m = make_mask(n)
- m2 = make_mask(m)
- self.assertTrue(m is m2)
- m3 = make_mask(m, copy=1)
- self.assertTrue(m is not m3)
-
- x1 = np.arange(5)
- y1 = array(x1, mask=m)
- self.assertTrue(y1._data is not x1)
- self.assertTrue(allequal(x1, y1._data))
- self.assertTrue(y1.mask is m)
-
- y1a = array(y1, copy=0)
- self.assertTrue(y1a.mask is y1.mask)
-
- y2 = array(x1, mask=m, copy=0)
- self.assertTrue(y2.mask is m)
- self.assertTrue(y2[2] is masked)
- y2[2] = 9
- self.assertTrue(y2[2] is not masked)
- self.assertTrue(y2.mask is not m)
- self.assertTrue(allequal(y2.mask, 0))
-
- y3 = array(x1 * 1.0, mask=m)
- self.assertTrue(filled(y3).dtype is (x1 * 1.0).dtype)
-
- x4 = arange(4)
- x4[2] = masked
- y4 = resize(x4, (8,))
- self.assertTrue(eq(concatenate([x4, x4]), y4))
- self.assertTrue(eq(getmask(y4), [0, 0, 1, 0, 0, 0, 1, 0]))
- y5 = repeat(x4, (2, 2, 2, 2), axis=0)
- self.assertTrue(eq(y5, [0, 0, 1, 1, 2, 2, 3, 3]))
- y6 = repeat(x4, 2, axis=0)
- self.assertTrue(eq(y5, y6))
+ with suppress_warnings() as sup:
+ sup.filter(
+ np.ma.core.MaskedArrayFutureWarning,
+ "setting an item on a masked array which has a "
+ "shared mask will not copy")
+
+ n = [0, 0, 1, 0, 0]
+ m = make_mask(n)
+ m2 = make_mask(m)
+ self.assertTrue(m is m2)
+ m3 = make_mask(m, copy=1)
+ self.assertTrue(m is not m3)
+
+ x1 = np.arange(5)
+ y1 = array(x1, mask=m)
+ self.assertTrue(y1._data is not x1)
+ self.assertTrue(allequal(x1, y1._data))
+ self.assertTrue(y1.mask is m)
+
+ y1a = array(y1, copy=0)
+ self.assertTrue(y1a.mask is y1.mask)
+
+ y2 = array(x1, mask=m, copy=0)
+ self.assertTrue(y2.mask is m)
+ self.assertTrue(y2[2] is masked)
+ y2[2] = 9
+ self.assertTrue(y2[2] is not masked)
+ self.assertTrue(y2.mask is not m)
+ self.assertTrue(allequal(y2.mask, 0))
+
+ y3 = array(x1 * 1.0, mask=m)
+ self.assertTrue(filled(y3).dtype is (x1 * 1.0).dtype)
+
+ x4 = arange(4)
+ x4[2] = masked
+ y4 = resize(x4, (8,))
+ self.assertTrue(eq(concatenate([x4, x4]), y4))
+ self.assertTrue(eq(getmask(y4), [0, 0, 1, 0, 0, 0, 1, 0]))
+ y5 = repeat(x4, (2, 2, 2, 2), axis=0)
+ self.assertTrue(eq(y5, [0, 0, 1, 1, 2, 2, 3, 3]))
+ y6 = repeat(x4, 2, axis=0)
+ self.assertTrue(eq(y5, y6))
def test_testPut(self):
# Test of put
- d = arange(5)
- n = [0, 0, 0, 1, 1]
- m = make_mask(n)
- x = array(d, mask=m)
- self.assertTrue(x[3] is masked)
- self.assertTrue(x[4] is masked)
- x[[1, 4]] = [10, 40]
- self.assertTrue(x.mask is not m)
- self.assertTrue(x[3] is masked)
- self.assertTrue(x[4] is not masked)
- self.assertTrue(eq(x, [0, 10, 2, -1, 40]))
-
- x = array(d, mask=m)
- x.put([0, 1, 2], [-1, 100, 200])
- self.assertTrue(eq(x, [-1, 100, 200, 0, 0]))
- self.assertTrue(x[3] is masked)
- self.assertTrue(x[4] is masked)
+ with suppress_warnings() as sup:
+ sup.filter(
+ np.ma.core.MaskedArrayFutureWarning,
+ "setting an item on a masked array which has a "
+ "shared mask will not copy")
+ d = arange(5)
+ n = [0, 0, 0, 1, 1]
+ m = make_mask(n)
+ x = array(d, mask=m)
+ self.assertTrue(x[3] is masked)
+ self.assertTrue(x[4] is masked)
+ x[[1, 4]] = [10, 40]
+ self.assertTrue(x.mask is not m)
+ self.assertTrue(x[3] is masked)
+ self.assertTrue(x[4] is not masked)
+ self.assertTrue(eq(x, [0, 10, 2, -1, 40]))
+
+ x = array(d, mask=m)
+ x.put([0, 1, 2], [-1, 100, 200])
+ self.assertTrue(eq(x, [-1, 100, 200, 0, 0]))
+ self.assertTrue(x[3] is masked)
+ self.assertTrue(x[4] is masked)
def test_testMaPut(self):
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
diff --git a/numpy/ma/tests/test_regression.py b/numpy/ma/tests/test_regression.py
index dba74d357..fc6cdfaff 100644
--- a/numpy/ma/tests/test_regression.py
+++ b/numpy/ma/tests/test_regression.py
@@ -4,7 +4,8 @@ import warnings
import numpy as np
from numpy.testing import (assert_, TestCase, assert_array_equal,
- assert_allclose, run_module_suite)
+ assert_allclose, run_module_suite,
+ suppress_warnings)
from numpy.compat import sixu
rlevel = 1
@@ -69,8 +70,9 @@ class TestRegression(TestCase):
# See gh-3336
x = np.ma.masked_equal([1, 2, 3, 4, 5], 4)
y = np.array([2, 2.5, 3.1, 3, 5])
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
+ # this test can be removed after deprecation.
+ with suppress_warnings() as sup:
+ sup.filter(DeprecationWarning, "bias and ddof have no effect")
r0 = np.ma.corrcoef(x, y, ddof=0)
r1 = np.ma.corrcoef(x, y, ddof=1)
# ddof should not have an effect (it gets cancelled out)