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

Method test_masked

numpy/lib/tests/test_function_base.py:2165–2179  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2163 assert_almost_equal(r, qz)
2164
2165 def test_masked(self):
2166 # Testing that masked arrays behave as if the function is 0 where
2167 # masked
2168 x = np.arange(5)
2169 y = x * x
2170 mask = x == 2
2171 ym = np.ma.array(y, mask=mask)
2172 r = 13.0 # sum(0.5 * (0 + 1) * 1.0 + 0.5 * (9 + 16))
2173 assert_almost_equal(trapz(ym, x), r)
2174
2175 xm = np.ma.array(x, mask=mask)
2176 assert_almost_equal(trapz(ym, xm), r)
2177
2178 xm = np.ma.array(x, mask=mask)
2179 assert_almost_equal(trapz(y, xm), r)
2180
2181
2182class TestSinc:

Callers

nothing calls this directly

Calls 2

assert_almost_equalFunction · 0.90
trapzFunction · 0.90

Tested by

no test coverage detected