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

Method test_2d

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

Source from the content-addressed store, hash-verified

957 np.ma.median(array([1,2,3],mask=[0,1,0])).shape )
958
959 def test_2d(self):
960 # Tests median w/ 2D
961 (n, p) = (101, 30)
962 x = masked_array(np.linspace(-1., 1., n),)
963 x[:10] = x[-10:] = masked
964 z = masked_array(np.empty((n, p), dtype=float))
965 z[:, 0] = x[:]
966 idx = np.arange(len(x))
967 for i in range(1, p):
968 np.random.shuffle(idx)
969 z[:, i] = x[idx]
970 assert_equal(median(z[:, 0]), 0)
971 assert_equal(median(z), 0)
972 assert_equal(median(z, axis=0), np.zeros(p))
973 assert_equal(median(z.T, axis=1), np.zeros(p))
974
975 def test_2d_waxis(self):
976 # Tests median w/ 2D arrays and different axis.

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
medianFunction · 0.90
linspaceMethod · 0.80

Tested by

no test coverage detected