Skip to content

Commit 97271bd

Browse files
committed
Used black to try to avoid errors.
1 parent e3c5f47 commit 97271bd

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

xarray/core/dataset.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,8 +3452,7 @@ def _assert_all_in_dataset(
34523452
# Drop variables
34533453
@overload
34543454
def drop(
3455-
self, labels: Union[Hashable, Iterable[Hashable]], *,
3456-
errors: str = "raise"
3455+
self, labels: Union[Hashable, Iterable[Hashable]], *, errors: str = "raise"
34573456
) -> "Dataset":
34583457
...
34593458

@@ -3464,7 +3463,7 @@ def drop(
34643463
) -> "Dataset":
34653464
...
34663465

3467-
def drop(self, labels=None, dim=None, *, errors='raise', **labels_kwargs):
3466+
def drop(self, labels=None, dim=None, *, errors="raise", **labels_kwargs):
34683467
"""Drop variables or index labels from this dataset.
34693468
34703469
Parameters
@@ -3509,15 +3508,13 @@ def drop(self, labels=None, dim=None, *, errors='raise', **labels_kwargs):
35093508
Data variables:
35103509
A (x, y) float64 -0.3944 -1.418 1.423 -1.041
35113510
"""
3512-
if errors not in ['raise', 'ignore']:
3511+
if errors not in ["raise", "ignore"]:
35133512
raise ValueError('errors must be either "raise" or "ignore"')
35143513

35153514
if labels_kwargs or utils.is_dict_like(labels):
3516-
labels_kwargs = utils.either_dict_or_kwargs(labels, labels_kwargs,
3517-
'drop')
3515+
labels_kwargs = utils.either_dict_or_kwargs(labels, labels_kwargs, "drop")
35183516
if dim is not None:
3519-
raise ValueError('cannot specify dim amd dict-like '
3520-
'arguments.')
3517+
raise ValueError("cannot specify dim amd dict-like " "arguments.")
35213518
ds = self
35223519
for dim, labels in labels_kwargs.items():
35233520
ds = ds._drop_labels(labels, dim, errors=errors)
@@ -3547,8 +3544,7 @@ def _drop_labels(self, labels=None, dim=None, errors="raise"):
35473544
try:
35483545
index = self.indexes[dim]
35493546
except KeyError:
3550-
raise ValueError(
3551-
"dimension %r does not have coordinate labels" % dim)
3547+
raise ValueError("dimension %r does not have coordinate labels" % dim)
35523548
new_index = index.drop(labels, errors=errors)
35533549
return self.loc[{dim: new_index}]
35543550

xarray/tests/test_dataset.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,29 +2163,28 @@ def test_drop_index_labels(self):
21632163

21642164
def test_drop_labels_by_keyword(self):
21652165
# Tests for #2910: Support for a additional `drop()` API.
2166-
data = Dataset({'A': (['x', 'y'], np.random.randn(2, 3)),
2167-
'x': ['a', 'b']})
2166+
data = Dataset({"A": (["x", "y"], np.random.randn(2, 3)), "x": ["a", "b"]})
21682167
# Basic functionality.
2169-
assert(len(data.coords['x']) == 2)
2168+
assert len(data.coords["x"]) == 2
21702169

21712170
with pytest.warns(DeprecationWarning):
2172-
ds1 = data.drop(['a'], dim='x')
2171+
ds1 = data.drop(["a"], dim="x")
21732172

2174-
ds2 = data.drop(x='a')
2175-
ds3 = data.drop(x=['a'])
2176-
ds4 = data.drop(x=['a', 'b'])
2177-
assert(len(ds1.coords['x']) == 1)
2178-
assert(len(ds2.coords['x']) == 1)
2179-
assert(len(ds3.coords['x']) == 1)
2180-
assert(len(ds4.coords['x']) == 0)
2173+
ds2 = data.drop(x="a")
2174+
ds3 = data.drop(x=["a"])
2175+
ds4 = data.drop(x=["a", "b"])
2176+
assert len(ds1.coords["x"]) == 1
2177+
assert len(ds2.coords["x"]) == 1
2178+
assert len(ds3.coords["x"]) == 1
2179+
assert len(ds4.coords["x"]) == 0
21812180

21822181
# Error handling if user tries both approaches.
21832182
with pytest.raises(ValueError):
2184-
data.drop(labels=['a'], x='a')
2183+
data.drop(labels=["a"], x="a")
21852184
with pytest.raises(ValueError):
2186-
data.drop(dim='x', x='a')
2185+
data.drop(dim="x", x="a")
21872186
with pytest.raises(ValueError):
2188-
data.drop(labels=['a'], dim='x', x='a')
2187+
data.drop(labels=["a"], dim="x", x="a")
21892188

21902189
def test_drop_dims(self):
21912190
data = xr.Dataset(

0 commit comments

Comments
 (0)