| 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() |