Skip to content

Apply assorted ruff preview rules #10465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply ruff/refurb preview rule FURB171
FURB171 Membership test against single-item container
  • Loading branch information
DimitriPapadopoulos committed Jun 29, 2025
commit b5d8bfa50cf6311331cb5e684dff63a85bfdaa4d
2 changes: 1 addition & 1 deletion xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ def guess_can_open(
) -> bool:
if isinstance(filename_or_obj, str | os.PathLike):
_, ext = os.path.splitext(filename_or_obj)
return ext in {".zarr"}
return ext == ".zarr"

return False

Expand Down
2 changes: 1 addition & 1 deletion xarray/computation/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _nanmean_ddof_object(ddof, value, axis=None, dtype=None, **kwargs):
# As dtype inference is impossible for object dtype, we assume float
# https://github.com/dask/dask/issues/3162
if dtype is None and value.dtype.kind == "O":
dtype = value.dtype if value.dtype.kind in ["cf"] else float
dtype = value.dtype if value.dtype.kind == "cf" else float

data = np.sum(value, axis=axis, dtype=dtype, **kwargs)
data = data / (valid_count - ddof)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2920,7 +2920,7 @@ def test_reduce_keepdims(self) -> None:
expected = DataArray(
orig.data.mean(keepdims=True),
dims=orig.dims,
coords={k: v for k, v in coords.items() if k in ["c"]},
coords={k: v for k, v in coords.items() if k == "c"},
)
assert_equal(actual, expected)

Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def test_reduce(dim_num, dtype, dask, func, skipna, aggdim):
if dask and not has_dask:
pytest.skip("requires dask")

if dask and skipna is False and dtype in [np.bool_]:
if dask and skipna is False and dtype == np.bool_:
pytest.skip("dask does not compute object-typed array")

rtol = 1e-04 if dtype == np.float32 else 1e-05
Expand Down
6 changes: 3 additions & 3 deletions xarray/tests/test_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_interpolate_1d(method: InterpOptions, dim: str, case: int) -> None:
if not has_scipy:
pytest.skip("scipy is not installed.")

if not has_dask and case in [1]:
if not has_dask and case == 1:
pytest.skip("dask is not installed in the environment.")

da = get_example_data(case)
Expand Down Expand Up @@ -433,7 +433,7 @@ def test_interpolate_nd_with_nan() -> None:
"case", [pytest.param(0, id="no_chunk"), pytest.param(1, id="chunk_y")]
)
def test_interpolate_scalar(method: InterpOptions, case: int) -> None:
if not has_dask and case in [1]:
if not has_dask and case == 1:
pytest.skip("dask is not installed in the environment.")

da = get_example_data(case)
Expand Down Expand Up @@ -463,7 +463,7 @@ def func(obj, new_x):
"case", [pytest.param(3, id="no_chunk"), pytest.param(4, id="chunked")]
)
def test_interpolate_nd_scalar(method: InterpOptions, case: int) -> None:
if not has_dask and case in [4]:
if not has_dask and case == 4:
pytest.skip("dask is not installed in the environment.")

da = get_example_data(case)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def test_ndrolling_reduce(
assert_allclose(actual, expected)
assert actual.sizes == expected.sizes

if name in ["mean"]:
if name == "mean":
# test our reimplementation of nanmean using np.nanmean
expected = getattr(rolling_obj.construct({"time": "tw", "x": "xw"}), name)(
["tw", "xw"]
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy