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

Method test_isin_additional

numpy/lib/tests/test_arraysetops.py:276–335  ·  view source on GitHub ↗
(self, kind)

Source from the content-addressed store, hash-verified

274
275 @pytest.mark.parametrize("kind", [None, "sort", "table"])
276 def test_isin_additional(self, kind):
277 # we use two different sizes for the b array here to test the
278 # two different paths in isin().
279 for mult in (1, 10):
280 # One check without np.array to make sure lists are handled correct
281 a = [5, 7, 1, 2]
282 b = [2, 4, 3, 1, 5] * mult
283 ec = np.array([True, False, True, True])
284 c = isin(a, b, assume_unique=True, kind=kind)
285 assert_array_equal(c, ec)
286
287 a[0] = 8
288 ec = np.array([False, False, True, True])
289 c = isin(a, b, assume_unique=True, kind=kind)
290 assert_array_equal(c, ec)
291
292 a[0], a[3] = 4, 8
293 ec = np.array([True, False, True, False])
294 c = isin(a, b, assume_unique=True, kind=kind)
295 assert_array_equal(c, ec)
296
297 a = np.array([5, 4, 5, 3, 4, 4, 3, 4, 3, 5, 2, 1, 5, 5])
298 b = [2, 3, 4] * mult
299 ec = [False, True, False, True, True, True, True, True, True,
300 False, True, False, False, False]
301 c = isin(a, b, kind=kind)
302 assert_array_equal(c, ec)
303
304 b = b + [5, 5, 4] * mult
305 ec = [True, True, True, True, True, True, True, True, True, True,
306 True, False, True, True]
307 c = isin(a, b, kind=kind)
308 assert_array_equal(c, ec)
309
310 a = np.array([5, 7, 1, 2])
311 b = np.array([2, 4, 3, 1, 5] * mult)
312 ec = np.array([True, False, True, True])
313 c = isin(a, b, kind=kind)
314 assert_array_equal(c, ec)
315
316 a = np.array([5, 7, 1, 1, 2])
317 b = np.array([2, 4, 3, 3, 1, 5] * mult)
318 ec = np.array([True, False, True, True, True])
319 c = isin(a, b, kind=kind)
320 assert_array_equal(c, ec)
321
322 a = np.array([5, 5])
323 b = np.array([2, 2] * mult)
324 ec = np.array([False, False])
325 c = isin(a, b, kind=kind)
326 assert_array_equal(c, ec)
327
328 a = np.array([5])
329 b = np.array([2])
330 ec = np.array([False])
331 c = isin(a, b, kind=kind)
332 assert_array_equal(c, ec)
333

Callers

nothing calls this directly

Calls 2

isinFunction · 0.90
assert_array_equalFunction · 0.90

Tested by

no test coverage detected