MCPcopy Create free account
hub / github.com/numpy/numpy / test_masked_all

Method test_masked_all

numpy/ma/tests/test_extras.py:38–66  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

36class TestGeneric:
37 #
38 def test_masked_all(self):
39 # Tests masked_all
40 # Standard dtype
41 test = masked_all((2,), dtype=float)
42 control = array([1, 1], mask=[1, 1], dtype=float)
43 assert_equal(test, control)
44 # Flexible dtype
45 dt = np.dtype({'names': ['a', 'b'], 'formats': ['f', 'f']})
46 test = masked_all((2,), dtype=dt)
47 control = array([(0, 0), (0, 0)], mask=[(1, 1), (1, 1)], dtype=dt)
48 assert_equal(test, control)
49 test = masked_all((2, 2), dtype=dt)
50 control = array([[(0, 0), (0, 0)], [(0, 0), (0, 0)]],
51 mask=[[(1, 1), (1, 1)], [(1, 1), (1, 1)]],
52 dtype=dt)
53 assert_equal(test, control)
54 # Nested dtype
55 dt = np.dtype([('a', 'f'), ('b', [('ba', 'f'), ('bb', 'f')])])
56 test = masked_all((2,), dtype=dt)
57 control = array([(1, (1, 1)), (1, (1, 1))],
58 mask=[(1, (1, 1)), (1, (1, 1))], dtype=dt)
59 assert_equal(test, control)
60 test = masked_all((2,), dtype=dt)
61 control = array([(1, (1, 1)), (1, (1, 1))],
62 mask=[(1, (1, 1)), (1, (1, 1))], dtype=dt)
63 assert_equal(test, control)
64 test = masked_all((1, 1), dtype=dt)
65 control = array([[(1, (1, 1))]], mask=[[(1, (1, 1))]], dtype=dt)
66 assert_equal(test, control)
67
68 def test_masked_all_with_object_nested(self):
69 # Test masked_all works with nested array with dtype of an 'object'

Callers

nothing calls this directly

Calls 4

masked_allFunction · 0.90
arrayFunction · 0.90
assert_equalFunction · 0.90
dtypeMethod · 0.45

Tested by

no test coverage detected