Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bffea7a

Browse files
sebergcertik
authored andcommitted
TST: Add test for in1d ravelling
The behavior of in1d is not really defined here, but it should be at least consistent over different execution branches. This is what it has been for most usages.
1 parent 42e5b80 commit bffea7a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

numpy/lib/tests/test_arraysetops.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ def test_in1d_char_array( self ):
189189

190190
assert_array_equal(c, ec)
191191

192+
def test_in1d_ravel(self):
193+
# Test that in1d ravels its input arrays. This is not documented
194+
# behavior however. The test is to ensure consistentency.
195+
a = np.arange(6).reshape(2,3)
196+
b = np.arange(3,9).reshape(3,2)
197+
long_b = np.arange(3, 63).reshape(30,2)
198+
ec = np.array([False, False, False, True, True, True])
199+
200+
assert_array_equal(in1d(a, b, assume_unique=True), ec)
201+
assert_array_equal(in1d(a, b, assume_unique=False), ec)
202+
assert_array_equal(in1d(a, long_b, assume_unique=True), ec)
203+
assert_array_equal(in1d(a, long_b, assume_unique=False), ec)
204+
192205
def test_union1d( self ):
193206
a = np.array( [5, 4, 7, 1, 2] )
194207
b = np.array( [2, 4, 3, 3, 2, 1, 5] )

0 commit comments

Comments
 (0)