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

Function test_argsort_float

numpy/core/tests/test_multiarray.py:10006–10017  ·  view source on GitHub ↗
(N, dtype)

Source from the content-addressed store, hash-verified

10004@pytest.mark.parametrize("N", np.arange(1, 512))
10005@pytest.mark.parametrize("dtype", [np.float32, np.float64])
10006def test_argsort_float(N, dtype):
10007 rnd = np.random.RandomState(116112)
10008 # (1) Regular data with a few nan: doesn't use vectorized sort
10009 arr = -0.5 + rnd.random(N).astype(dtype)
10010 arr[rnd.choice(arr.shape[0], 3)] = np.nan
10011 assert_arg_sorted(arr, np.argsort(arr, kind='quick'))
10012
10013 # (2) Random data with inf at the end of array
10014 # See: https://github.com/intel/x86-simd-sort/pull/39
10015 arr = -0.5 + rnd.rand(N).astype(dtype)
10016 arr[N-1] = np.inf
10017 assert_arg_sorted(arr, np.argsort(arr, kind='quick'))
10018
10019
10020@pytest.mark.parametrize("N", np.arange(2, 512))

Callers

nothing calls this directly

Calls 4

assert_arg_sortedFunction · 0.85
astypeMethod · 0.80
randomMethod · 0.80
argsortMethod · 0.45

Tested by

no test coverage detected