Skip to content

Apply ruff rule RUF007 #9739

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 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ ignore = [
"RUF002",
"RUF003",
"RUF005",
"RUF007",
"RUF012",
]
extend-select = [
Expand Down
4 changes: 2 additions & 2 deletions xarray/groupers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import datetime
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from itertools import pairwise
from typing import TYPE_CHECKING, Any, Literal, cast

import numpy as np
Expand Down Expand Up @@ -496,8 +497,7 @@ def factorize(self, group: T_Group) -> EncodedGroups:
full_index, first_items, codes_ = self._get_index_and_items()
sbins = first_items.values.astype(np.int64)
group_indices: GroupIndices = tuple(
[slice(i, j) for i, j in zip(sbins[:-1], sbins[1:], strict=True)]
+ [slice(sbins[-1], None)]
[slice(i, j) for i, j in pairwise(sbins)] + [slice(sbins[-1], None)]
)

unique_coord = Variable(
Expand Down
3 changes: 2 additions & 1 deletion xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import operator
import warnings
from itertools import pairwise
from unittest import mock

import numpy as np
Expand Down Expand Up @@ -1732,7 +1733,7 @@ def test_groupby_bins_multidim(self) -> None:
bincoord = np.array(
[
pd.Interval(left, right, closed="right")
for left, right in zip(bins[:-1], bins[1:], strict=True)
for left, right in pairwise(bins)
],
dtype=object,
)
Expand Down
Loading