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

Function test_argsort_int

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

Source from the content-addressed store, hash-verified

10020@pytest.mark.parametrize("N", np.arange(2, 512))
10021@pytest.mark.parametrize("dtype", [np.int32, np.uint32, np.int64, np.uint64])
10022def test_argsort_int(N, dtype):
10023 rnd = np.random.RandomState(1100710816)
10024 # (1) random data with min and max values
10025 minv = np.iinfo(dtype).min
10026 maxv = np.iinfo(dtype).max
10027 arr = rnd.randint(low=minv, high=maxv, size=N, dtype=dtype)
10028 i, j = rnd.choice(N, 2, replace=False)
10029 arr[i] = minv
10030 arr[j] = maxv
10031 assert_arg_sorted(arr, np.argsort(arr, kind='quick'))
10032
10033 # (2) random data with max value at the end of array
10034 # See: https://github.com/intel/x86-simd-sort/pull/39
10035 arr = rnd.randint(low=minv, high=maxv, size=N, dtype=dtype)
10036 arr[N-1] = maxv
10037 assert_arg_sorted(arr, np.argsort(arr, kind='quick'))
10038
10039
10040@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")

Callers

nothing calls this directly

Calls 2

assert_arg_sortedFunction · 0.85
argsortMethod · 0.45

Tested by

no test coverage detected