(self)
| 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] |
nothing calls this directly
no test coverage detected