Skip to content

Commit 549a58f

Browse files
committed
Fixed bug in 41e8cae running doctest & format issue for docs
1 parent 41e8cae commit 549a58f

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

xarray/core/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,10 +1390,10 @@ def isin(self, test_elements, tolerance=None):
13901390
Parameters
13911391
----------
13921392
test_elements : array_like
1393-
tolerance : dtype
13941393
The values against which to test each value of `element`.
1395-
This argument is flattened if an array or array_like.
13961394
See numpy notes for behavior with non-array-like parameters.
1395+
tolerance : dtype
1396+
Optional parameter for acceptible equal tolerance.
13971397
13981398
Returns
13991399
-------
@@ -1409,7 +1409,7 @@ def isin(self, test_elements, tolerance=None):
14091409
Dimensions without coordinates: x
14101410
14111411
>>> array = xr.DataArray([1, 2, 3], dims="x")
1412-
>>> array.isin([1.1, 2.9], tolerance = 0.2)
1412+
>>> array.isin([1.1, 2.9], tolerance=0.2)
14131413
<xarray.DataArray (x: 3)>
14141414
array([ True, False, True])
14151415
Dimensions without coordinates: x
@@ -1435,7 +1435,7 @@ def isin(self, test_elements, tolerance=None):
14351435
test_elements = test_elements.data
14361436

14371437
if tolerance:
1438-
# non-zero & None arguments
1438+
# non-zero tolerance arguments
14391439
return apply_ufunc(
14401440
duck_array_ops.isin_tolerance,
14411441
self,

xarray/core/duck_array_ops.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
import pandas as pd
1414
from numpy import all as array_all # noqa
1515
from numpy import any as array_any # noqa
16-
from numpy import zeros_like # noqa
17-
from numpy import around, broadcast_to # noqa
16+
from numpy import zeros_like # noqa; noqa
17+
from numpy import around, broadcast_to
1818
from numpy import concatenate as _concatenate
19-
from numpy import einsum, isclose, isin, isnan, isnat, pad # noqa
19+
from numpy import einsum, isclose, isin, isnan, isnat, pad
2020
from numpy import stack as _stack
21-
from numpy import take, tensordot, transpose, unravel_index # noqa
21+
from numpy import take, tensordot, transpose, unravel_index
2222
from numpy import where as _where
2323

2424
from . import dask_array_compat, dask_array_ops, dtypes, npcompat, nputils
@@ -472,20 +472,21 @@ def isin_tolerance(self, test_elements, tolerance):
472472
Parameters
473473
----------
474474
self : numpy.array_like
475-
test_elements : numpy.array_like
475+
test_elements : array_like
476476
tolerance : dtype
477-
Absolute value of accemptable range between self and test_elements.
477+
Absolute value of acceptable range between self and test_elements.
478478
479479
Returns
480480
-------
481481
array_like : Same shape as self, but contains bool values.
482482
483483
Notes
484484
-----
485-
Vectorized comparasons elementwise require immense memory for larger datasets
486-
because it generates np.array with shape (self.shape, test_elements.shape)
485+
Vectorized comparisons elementwise require immense memory for larger datasets
486+
because it generates np.array with shape (*self.shape, *test_elements.shape)
487487
488488
"""
489+
test_elements = np.asarray(test_elements)
489490
merge_axis = (
490491
*[
491492
mergeaxis

xarray/tests/test_duck_array_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
count,
1616
first,
1717
gradient,
18+
isin_tolerance,
1819
last,
1920
least_squares,
2021
mean,
@@ -23,7 +24,6 @@
2324
push,
2425
py_timedelta_to_float,
2526
stack,
26-
isin_tolerance,
2727
timedelta_to_numeric,
2828
where,
2929
)

0 commit comments

Comments
 (0)