Skip to content

Commit e2842aa

Browse files
Unnecessary generator (#10506)
1 parent a8de733 commit e2842aa

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

xarray/core/indexes.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,12 @@ def concat(
768768

769769
if not indexes:
770770
coord_dtype = None
771-
elif len(set(idx.coord_dtype for idx in indexes)) == 1:
772-
coord_dtype = indexes[0].coord_dtype
773771
else:
774-
coord_dtype = np.result_type(*[idx.coord_dtype for idx in indexes])
772+
indexes_coord_dtypes = {idx.coord_dtype for idx in indexes}
773+
if len(indexes_coord_dtypes) == 1:
774+
coord_dtype = next(iter(indexes_coord_dtypes))
775+
else:
776+
coord_dtype = np.result_type(*indexes_coord_dtypes)
775777

776778
return cls(new_pd_index, dim=dim, coord_dtype=coord_dtype)
777779

xarray/core/treenode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def relative_to(self: NamedNode, other: NamedNode) -> str:
752752
)
753753

754754
this_path = NodePath(self.path)
755-
if other.path in list(parent.path for parent in (self, *self.parents)):
755+
if any(other.path == parent.path for parent in (self, *self.parents)):
756756
return str(this_path.relative_to(other.path))
757757
else:
758758
common_ancestor = self.find_common_ancestor(other)

xarray/groupers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,10 @@ def season_to_month_tuple(seasons: Sequence[str]) -> tuple[tuple[int, ...], ...]
617617
((12, 1, 2, 3), (9, 10, 11, 12))
618618
"""
619619
initials = "JFMAMJJASOND"
620-
starts = dict(
621-
("".join(s), i + 1)
620+
starts = {
621+
"".join(s): i + 1
622622
for s, i in zip(sliding_window(2, initials + "J"), range(12), strict=True)
623-
)
623+
}
624624
result: list[tuple[int, ...]] = []
625625
for i, season in enumerate(seasons):
626626
if len(season) == 1:

0 commit comments

Comments
 (0)