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

Method test_small_large

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

Source from the content-addressed store, hash-verified

861 assert_almost_equal(res, tgt)
862
863 def test_small_large(self):
864 # test the small and large code paths, current cutoff 400 elements
865 for s in [5, 20, 51, 200, 1000]:
866 d = np.random.randn(4, s)
867 # Randomly set some elements to NaN:
868 w = np.random.randint(0, d.size, size=d.size // 5)
869 d.ravel()[w] = np.nan
870 d[:,0] = 1. # ensure at least one good value
871 # use normal median without nans to compare
872 tgt = []
873 for x in d:
874 nonan = np.compress(~np.isnan(x), x)
875 tgt.append(np.median(nonan, overwrite_input=True))
876
877 assert_array_equal(np.nanmedian(d, axis=-1), tgt)
878
879 def test_result_values(self):
880 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