Пример #1
0
 def test_masked_all(self):
     # Tests masked_all
     # Standard dtype
     test = masked_all((2,), dtype=float)
     control = array([1, 1], mask=[1, 1], dtype=float)
     assert_equal(test, control)
     # Flexible dtype
     dt = np.dtype({'names': ['a', 'b'], 'formats': ['f', 'f']})
     test = masked_all((2,), dtype=dt)
     control = array([(0, 0), (0, 0)], mask=[(1, 1), (1, 1)], dtype=dt)
     assert_equal(test, control)
     test = masked_all((2, 2), dtype=dt)
     control = array([[(0, 0), (0, 0)], [(0, 0), (0, 0)]],
                     mask=[[(1, 1), (1, 1)], [(1, 1), (1, 1)]],
                     dtype=dt)
     assert_equal(test, control)
     # Nested dtype
     dt = np.dtype([('a', 'f'), ('b', [('ba', 'f'), ('bb', 'f')])])
     test = masked_all((2,), dtype=dt)
     control = array([(1, (1, 1)), (1, (1, 1))],
                     mask=[(1, (1, 1)), (1, (1, 1))], dtype=dt)
     assert_equal(test, control)
     test = masked_all((2,), dtype=dt)
     control = array([(1, (1, 1)), (1, (1, 1))],
                     mask=[(1, (1, 1)), (1, (1, 1))], dtype=dt)
     assert_equal(test, control)
     test = masked_all((1, 1), dtype=dt)
     control = array([[(1, (1, 1))]], mask=[[(1, (1, 1))]], dtype=dt)
     assert_equal(test, control)
Пример #2
0
 def test_masked_all(self):
     # Tests masked_all
     # Standard dtype
     test = masked_all((2, ), dtype=float)
     control = array([1, 1], mask=[1, 1], dtype=float)
     assert_equal(test, control)
     # Flexible dtype
     dt = np.dtype({'names': ['a', 'b'], 'formats': ['f', 'f']})
     test = masked_all((2, ), dtype=dt)
     control = array([(0, 0), (0, 0)], mask=[(1, 1), (1, 1)], dtype=dt)
     assert_equal(test, control)
     test = masked_all((2, 2), dtype=dt)
     control = array([[(0, 0), (0, 0)], [(0, 0), (0, 0)]],
                     mask=[[(1, 1), (1, 1)], [(1, 1), (1, 1)]],
                     dtype=dt)
     assert_equal(test, control)
     # Nested dtype
     dt = np.dtype([('a', 'f'), ('b', [('ba', 'f'), ('bb', 'f')])])
     test = masked_all((2, ), dtype=dt)
     control = array([(1, (1, 1)), (1, (1, 1))],
                     mask=[(1, (1, 1)), (1, (1, 1))],
                     dtype=dt)
     assert_equal(test, control)
     test = masked_all((2, ), dtype=dt)
     control = array([(1, (1, 1)), (1, (1, 1))],
                     mask=[(1, (1, 1)), (1, (1, 1))],
                     dtype=dt)
     assert_equal(test, control)
     test = masked_all((1, 1), dtype=dt)
     control = array([[(1, (1, 1))]], mask=[[(1, (1, 1))]], dtype=dt)
     assert_equal(test, control)
Пример #3
0
 def test_masked_all(self):
     # Tests masked_all
     # Standard dtype
     test = masked_all((2,), dtype=float)
     control = array([1, 1], mask=[1, 1], dtype=float)
     assert_equal(test, control)
     # Flexible dtype
     dt = np.dtype({"names": ["a", "b"], "formats": ["f", "f"]})
     test = masked_all((2,), dtype=dt)
     control = array([(0, 0), (0, 0)], mask=[(1, 1), (1, 1)], dtype=dt)
     assert_equal(test, control)
     test = masked_all((2, 2), dtype=dt)
     control = array([[(0, 0), (0, 0)], [(0, 0), (0, 0)]], mask=[[(1, 1), (1, 1)], [(1, 1), (1, 1)]], dtype=dt)
     assert_equal(test, control)
     # Nested dtype
     dt = np.dtype([("a", "f"), ("b", [("ba", "f"), ("bb", "f")])])
     test = masked_all((2,), dtype=dt)
     control = array([(1, (1, 1)), (1, (1, 1))], mask=[(1, (1, 1)), (1, (1, 1))], dtype=dt)
     assert_equal(test, control)
     test = masked_all((2,), dtype=dt)
     control = array([(1, (1, 1)), (1, (1, 1))], mask=[(1, (1, 1)), (1, (1, 1))], dtype=dt)
     assert_equal(test, control)
     test = masked_all((1, 1), dtype=dt)
     control = array([[(1, (1, 1))]], mask=[[(1, (1, 1))]], dtype=dt)
     assert_equal(test, control)