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

Method test_isin

numpy/ma/tests/test_extras.py:1676–1695  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1674 assert_equal(test, [1, 2, 3, 4, 5, 6])
1675
1676 def test_isin(self):
1677 # the tests for in1d cover most of isin's behavior
1678 # if in1d is removed, would need to change those tests to test
1679 # isin instead.
1680 a = np.arange(24).reshape([2, 3, 4])
1681 mask = np.zeros([2, 3, 4])
1682 mask[1, 2, 0] = 1
1683 a = array(a, mask=mask)
1684 b = array(data=[0, 10, 20, 30, 1, 3, 11, 22, 33],
1685 mask=[0, 1, 0, 1, 0, 1, 0, 1, 0])
1686 ec = zeros((2, 3, 4), dtype=bool)
1687 ec[0, 0, 0] = True
1688 ec[0, 0, 1] = True
1689 ec[0, 2, 3] = True
1690 c = isin(a, b)
1691 assert_(isinstance(c, MaskedArray))
1692 assert_array_equal(c, ec)
1693 # compare results of np.isin to ma.isin
1694 d = np.isin(a, b[~b.mask]) & ~a.mask
1695 assert_array_equal(c, d)
1696
1697 def test_in1d(self):
1698 # Test in1d

Callers

nothing calls this directly

Calls 6

arrayFunction · 0.90
isinFunction · 0.90
assert_array_equalFunction · 0.90
zerosFunction · 0.85
assert_Function · 0.85
reshapeMethod · 0.80

Tested by

no test coverage detected