MCPcopy Index your code
hub / github.com/numpy/numpy / test_find

Method test_find

numpy/_core/tests/test_defchararray.py:275–289  ·  view source on GitHub ↗
(self, dtype, encode)

Source from the content-addressed store, hash-verified

273 ("S", lambda x: x.encode('ascii')),
274 ])
275 def test_find(self, dtype, encode):
276 A = self.A().astype(dtype)
277 assert_(issubclass(A.find(encode('a')).dtype.type, np.integer))
278 assert_array_equal(A.find(encode('a')),
279 [[1, -1], [-1, 6], [-1, -1]])
280 assert_array_equal(A.find(encode('3')),
281 [[-1, -1], [2, -1], [2, -1]])
282 assert_array_equal(A.find(encode('a'), 0, 2),
283 [[1, -1], [-1, -1], [-1, -1]])
284 assert_array_equal(A.find([encode('1'), encode('P')]),
285 [[-1, -1], [0, -1], [0, 1]])
286 C = (np.array(['ABCDEFGHIJKLMNOPQRSTUVWXYZ',
287 '01234567890123456789012345'])
288 .view(np.char.chararray)).astype(dtype)
289 assert_array_equal(C.find(encode('M')), [12, -1])
290
291 def test_index(self):
292 A = self.A()

Callers

nothing calls this directly

Calls 7

AMethod · 0.95
assert_Function · 0.90
assert_array_equalFunction · 0.90
encodeFunction · 0.85
astypeMethod · 0.80
findMethod · 0.80
viewMethod · 0.45

Tested by

no test coverage detected