File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ def in1d(
4242 mask |= x1 == a
4343 return mask
4444
45+ rev_idx = xp .empty (0 ) # placeholder
4546 if not assume_unique :
4647 x1 , rev_idx = xp .unique_inverse (x1 )
4748 x2 = xp .unique_values (x2 )
@@ -61,7 +62,4 @@ def in1d(
6162
6263 if assume_unique :
6364 return ret [: x1 .shape [0 ]]
64- # https://github.com/KotlinIsland/basedmypy/issues/826
65- # https://github.com/pylint-dev/pylint/issues/10095
66- # pylint: disable=possibly-used-before-assignment
67- return xp .take (ret , rev_idx , axis = 0 ) # type: ignore[possibly-undefined] # pyright: ignore[reportPossiblyUnboundVariable]
65+ return xp .take (ret , rev_idx , axis = 0 )
Original file line number Diff line number Diff line change 11from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
22
3+ import typing
4+
35# data-apis/array-api-strict#6
46import array_api_strict as xp # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs]
7+ import pytest
58from numpy .testing import assert_array_equal
69
710from array_api_extra ._lib ._utils import in1d
811
12+ if typing .TYPE_CHECKING :
13+ from array_api_extra ._lib ._typing import Array
14+
915
1016# some test coverage already provided by TestSetDiff1D
1117class TestIn1D :
12- def test_no_invert_assume_unique (self ):
18+ # cover both code paths
19+ @pytest .mark .parametrize ("x2" , [xp .arange (9 ), xp .arange (15 )])
20+ def test_no_invert_assume_unique (self , x2 : Array ):
1321 x1 = xp .asarray ([3 , 8 , 20 ])
14- x2 = xp .arange (15 )
1522 expected = xp .asarray ([True , True , False ])
1623 actual = in1d (x1 , x2 , xp = xp )
1724 assert_array_equal (actual , expected )
You can’t perform that action at this time.
0 commit comments