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

Method test_object

numpy/core/tests/test_multiarray.py:5239–5253  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5237 assert_array_equal(idx, expected_idx)
5238
5239 def test_object(self): # gh-6312
5240 a = np.random.choice(10, 1000)
5241 b = np.random.choice(['abc', 'xy', 'wz', 'efghi', 'qwst', 'x'], 1000)
5242
5243 for u in a, b:
5244 left = np.lexsort((u.astype('O'),))
5245 right = np.argsort(u, kind='mergesort')
5246 assert_array_equal(left, right)
5247
5248 for u, v in (a, b), (b, a):
5249 idx = np.lexsort((u, v))
5250 assert_array_equal(idx, np.lexsort((u.astype('O'), v)))
5251 assert_array_equal(idx, np.lexsort((u, v.astype('O'))))
5252 u, v = np.array(u, dtype='object'), np.array(v, dtype='object')
5253 assert_array_equal(idx, np.lexsort((u, v)))
5254
5255 def test_invalid_axis(self): # gh-7528
5256 x = np.linspace(0., 1., 42*3).reshape(42, 3)

Callers

nothing calls this directly

Calls 3

assert_array_equalFunction · 0.90
astypeMethod · 0.80
argsortMethod · 0.45

Tested by

no test coverage detected