Skip to content

Commit b696415

Browse files
Unnecessary generator - rewrite as a list comprehension
1 parent 8528ef5 commit b696415

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

xarray/core/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def factorize(self) -> EncodedGroups:
540540
_flatcodes = where(mask.data, -1, _flatcodes)
541541

542542
full_index = pd.MultiIndex.from_product(
543-
list(grouper.full_index.values for grouper in groupers),
543+
[grouper.full_index.values for grouper in groupers],
544544
names=tuple(grouper.name for grouper in groupers),
545545
)
546546
if not full_index.is_unique:

xarray/core/treenode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,12 +786,12 @@ def _path_to_ancestor(self, ancestor: NamedNode) -> NodePath:
786786
raise NotFoundInTreeError(
787787
"Cannot find relative path to ancestor because nodes do not lie within the same tree"
788788
)
789-
if ancestor.path not in list(a.path for a in (self, *self.parents)):
789+
if ancestor.path not in [a.path for a in (self, *self.parents)]:
790790
raise NotFoundInTreeError(
791791
"Cannot find relative path to ancestor because given node is not an ancestor of this node"
792792
)
793793

794-
parents_paths = list(parent.path for parent in (self, *self.parents))
794+
parents_paths = [parent.path for parent in (self, *self.parents)]
795795
generation_gap = list(parents_paths).index(ancestor.path)
796796
path_upwards = "../" * generation_gap if generation_gap > 0 else "."
797797
return NodePath(path_upwards)

xarray/structure/concat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def process_subset_opt(opt, subset):
418418
elif opt == "all":
419419
concat_over.update(
420420
set().union(
421-
*list(set(getattr(d, subset)) - set(d.dims) for d in datasets)
421+
*[set(getattr(d, subset)) - set(d.dims) for d in datasets]
422422
)
423423
)
424424
elif opt == "minimal":

xarray/tests/test_datatree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ def test_nones(self) -> None:
837837

838838
def test_full(self, simple_datatree) -> None:
839839
dt = simple_datatree
840-
paths = list(node.path for node in dt.subtree)
840+
paths = [node.path for node in dt.subtree]
841841
assert paths == [
842842
"/",
843843
"/set1",

xarray/tests/test_units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,7 @@ def test_searchsorted(self, func, unit, error, dtype):
26502650
data_array = xr.DataArray(data=array)
26512651

26522652
scalar_types = (int, float)
2653-
args = list(value * unit for value in func.args)
2653+
args = [value * unit for value in func.args]
26542654
kwargs = {
26552655
key: (value * unit if isinstance(value, scalar_types) else value)
26562656
for key, value in func.kwargs.items()
@@ -2708,7 +2708,7 @@ def test_numpy_methods_with_args(self, func, unit, error, dtype):
27082708
data_array = xr.DataArray(data=array)
27092709

27102710
scalar_types = (int, float)
2711-
args = list(value * unit for value in func.args)
2711+
args = [value * unit for value in func.args]
27122712
kwargs = {
27132713
key: (value * unit if isinstance(value, scalar_types) else value)
27142714
for key, value in func.kwargs.items()

0 commit comments

Comments
 (0)