MCPcopy Index your code
hub / github.com/numpy/numpy / test_small_large

Method test_small_large

numpy/lib/tests/test_nanfunctions.py:924–938  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

922 assert_almost_equal(res, tgt)
923
924 def test_small_large(self):
925 # test the small and large code paths, current cutoff 400 elements
926 for s in [5, 20, 51, 200, 1000]:
927 d = np.random.randn(4, s)
928 # Randomly set some elements to NaN:
929 w = np.random.randint(0, d.size, size=d.size // 5)
930 d.ravel()[w] = np.nan
931 d[:, 0] = 1. # ensure at least one good value
932 # use normal median without nans to compare
933 tgt = []
934 for x in d:
935 nonan = np.compress(~np.isnan(x), x)
936 tgt.append(np.median(nonan, overwrite_input=True))
937
938 assert_array_equal(np.nanmedian(d, axis=-1), tgt)
939
940 def test_result_values(self):
941 tgt = [np.median(d) for d in _rdat]

Callers

nothing calls this directly

Calls 3

assert_array_equalFunction · 0.90
compressMethod · 0.80
ravelMethod · 0.45

Tested by

no test coverage detected