7
7
import pytest
8
8
from numpy import array , nan
9
9
10
- from xarray import DataArray , Dataset , cftime_range , concat , testing
10
+ from xarray import DataArray , Dataset , cftime_range , concat
11
11
from xarray .core import dtypes , duck_array_ops
12
12
from xarray .core .duck_array_ops import (
13
13
array_notnull_equiv ,
@@ -902,6 +902,7 @@ def test_push_dask():
902
902
def test_isin_tolerance (shape , tolerance , dask_for_A , dask_for_B ):
903
903
if (dask_for_A or dask_for_B ) and not has_dask :
904
904
pytest .skip ("requires dask" )
905
+ from xarray .testing import assert_duckarray_equal
905
906
906
907
in_margin = tolerance / 2 # measure within acceptable margin
907
908
arrayA = np .arange (- 10.0 , 10.0 , 0.1 ).reshape (shape )
@@ -925,14 +926,17 @@ def test_isin_tolerance(shape, tolerance, dask_for_A, dask_for_B):
925
926
# test function
926
927
actual = isin_tolerance (arrayA , arrayB , tolerance )
927
928
928
- testing .assert_duckarray_equal (actual , expected )
929
- assert type (actual ) == type (expected )
929
+ assert_duckarray_equal (actual , expected )
930
+ if dask_for_A :
931
+ assert isinstance (actual , dask_array_type )
932
+ else :
933
+ assert isinstance (actual , np .ndarray )
930
934
else : # test only using numpy
931
935
for offset_direction in [1 , - 1 ]:
932
936
# generate test set
933
937
arrayB = - 99 * (~ expected ) + (in_margin + arrayA * expected )
934
938
# test function
935
939
actual = isin_tolerance (arrayA , arrayB , tolerance )
936
940
937
- testing . assert_duckarray_equal (actual , expected )
938
- assert type (actual ) == type ( expected )
941
+ assert_duckarray_equal (actual , expected )
942
+ assert isinstance (actual , np . ndarray )
0 commit comments