diff options
Diffstat (limited to 'numpy/ma/tests/test_old_ma.py')
-rw-r--r-- | numpy/ma/tests/test_old_ma.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py index 2b3034f9c..083e51125 100644 --- a/numpy/ma/tests/test_old_ma.py +++ b/numpy/ma/tests/test_old_ma.py @@ -1,5 +1,7 @@ from functools import reduce +import pytest + import numpy as np import numpy.core.umath as umath import numpy.core.fromnumeric as fromnumeric @@ -33,7 +35,7 @@ def eq(v, w, msg=''): class TestMa: - def setup(self): + def setup_method(self): x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. @@ -62,27 +64,26 @@ class TestMa: assert_(eq(filled(xm, 1.e20), xf)) assert_(eq(x, xm)) - def test_testBasic2d(self): + @pytest.mark.parametrize("s", [(4, 3), (6, 2)]) + def test_testBasic2d(self, s): # Test of basic array creation and properties in 2 dimensions. - for s in [(4, 3), (6, 2)]: - (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d - x.shape = s - y.shape = s - xm.shape = s - ym.shape = s - xf.shape = s - - assert_(not isMaskedArray(x)) - assert_(isMaskedArray(xm)) - assert_equal(shape(xm), s) - assert_equal(xm.shape, s) - assert_equal(xm.size, reduce(lambda x, y:x * y, s)) - assert_equal(count(xm), - len(m1) - reduce(lambda x, y:x + y, m1)) - assert_(eq(xm, xf)) - assert_(eq(filled(xm, 1.e20), xf)) - assert_(eq(x, xm)) - self.setup() + (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d + x.shape = s + y.shape = s + xm.shape = s + ym.shape = s + xf.shape = s + + assert_(not isMaskedArray(x)) + assert_(isMaskedArray(xm)) + assert_equal(shape(xm), s) + assert_equal(xm.shape, s) + assert_equal(xm.size, reduce(lambda x, y:x * y, s)) + assert_equal(count(xm), + len(m1) - reduce(lambda x, y:x + y, m1)) + assert_(eq(xm, xf)) + assert_(eq(filled(xm, 1.e20), xf)) + assert_(eq(x, xm)) def test_testArithmetic(self): # Test of basic arithmetic. @@ -715,7 +716,7 @@ class TestMa: class TestUfuncs: - def setup(self): + def setup_method(self): self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6), array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),) @@ -781,7 +782,7 @@ class TestUfuncs: class TestArrayMethods: - def setup(self): + def setup_method(self): x = np.array([8.375, 7.545, 8.828, 8.5, 1.757, 5.928, 8.43, 7.78, 9.865, 5.878, 8.979, 4.732, 3.012, 6.022, 5.095, 3.116, 5.238, 3.957, |