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