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

Method test_2d

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

Source from the content-addressed store, hash-verified

1045 np.ma.median(array([1, 2, 3], mask=[0, 1, 0])).shape)
1046
1047 def test_2d(self):
1048 # Tests median w/ 2D
1049 (n, p) = (101, 30)
1050 x = masked_array(np.linspace(-1., 1., n),)
1051 x[:10] = x[-10:] = masked
1052 z = masked_array(np.empty((n, p), dtype=float))
1053 z[:, 0] = x[:]
1054 idx = np.arange(len(x))
1055 for i in range(1, p):
1056 np.random.shuffle(idx)
1057 z[:, i] = x[idx]
1058 assert_equal(median(z[:, 0]), 0)
1059 assert_equal(median(z), 0)
1060 assert_equal(median(z, axis=0), np.zeros(p))
1061 assert_equal(median(z.T, axis=1), np.zeros(p))
1062
1063 def test_2d_waxis(self):
1064 # 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