Skip to content

Commit 0cc1b6a

Browse files
committed
Using local assert_duckarray_equal & array type with isinstance.
1 parent e2a2675 commit 0cc1b6a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

xarray/tests/test_duck_array_ops.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
from numpy import array, nan
99

10-
from xarray import DataArray, Dataset, cftime_range, concat, testing
10+
from xarray import DataArray, Dataset, cftime_range, concat
1111
from xarray.core import dtypes, duck_array_ops
1212
from xarray.core.duck_array_ops import (
1313
array_notnull_equiv,
@@ -902,6 +902,7 @@ def test_push_dask():
902902
def test_isin_tolerance(shape, tolerance, dask_for_A, dask_for_B):
903903
if (dask_for_A or dask_for_B) and not has_dask:
904904
pytest.skip("requires dask")
905+
from xarray.testing import assert_duckarray_equal
905906

906907
in_margin = tolerance / 2 # measure within acceptable margin
907908
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):
925926
# test function
926927
actual = isin_tolerance(arrayA, arrayB, tolerance)
927928

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)
930934
else: # test only using numpy
931935
for offset_direction in [1, -1]:
932936
# generate test set
933937
arrayB = -99 * (~expected) + (in_margin + arrayA * expected)
934938
# test function
935939
actual = isin_tolerance(arrayA, arrayB, tolerance)
936940

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

Comments
 (0)