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

Method test_sort_structured

numpy/core/tests/test_multiarray.py:2143–2158  ·  view source on GitHub ↗
(self, dt, step)

Source from the content-addressed store, hash-verified

2141 np.dtype([('f', float), ('i', object)])])
2142 @pytest.mark.parametrize("step", [1, 2])
2143 def test_sort_structured(self, dt, step):
2144 # test record array sorts.
2145 a = np.array([(i, i) for i in range(101*step)], dtype=dt)
2146 b = a[::-1]
2147 for kind in ['q', 'h', 'm']:
2148 msg = "kind=%s" % kind
2149 c = a.copy()[::step]
2150 indx = c.argsort(kind=kind)
2151 c.sort(kind=kind)
2152 assert_equal(c, a[::step], msg)
2153 assert_equal(a[::step][indx], a[::step], msg)
2154 c = b.copy()[::step]
2155 indx = c.argsort(kind=kind)
2156 c.sort(kind=kind)
2157 assert_equal(c, a[step-1::step], msg)
2158 assert_equal(b[::step][indx], a[step-1::step], msg)
2159
2160 @pytest.mark.parametrize('dtype', ['datetime64[D]', 'timedelta64[D]'])
2161 def test_sort_time(self, dtype):

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
sortMethod · 0.80
copyMethod · 0.45
argsortMethod · 0.45

Tested by

no test coverage detected