Skip to content

chore: Remove unnecessary comprehension #4026

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 2 commits into from
May 5, 2020
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
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ Internal Changes
- Use ``async`` / ``await`` for the asynchronous distributed
tests. (:issue:`3987`, :pull:`3989`)
By `Justus Magin <https://github.com/keewis>`_.
- Remove unnecessary comprehensions becuase the built-in functions like
``all``, ``any``, ``enumerate``, ``sum``, ``tuple`` etc. can work directly with a
generator expression. (:pull:`4026`)
By `Prajjwal Nijhara <https://github.com/pnijhara>`_.

.. _whats-new.0.15.1:

Expand Down
2 changes: 1 addition & 1 deletion xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def check_reduce_dims(reduce_dims, dimensions):
if reduce_dims is not ...:
if is_scalar(reduce_dims):
reduce_dims = [reduce_dims]
if any([dim not in dimensions for dim in reduce_dims]):
if any(dim not in dimensions for dim in reduce_dims):
raise ValueError(
"cannot reduce over dimensions %r. expected either '...' to reduce over all dimensions or one or more of %r."
% (reduce_dims, dimensions)
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/pdcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ def count_not_none(*args) -> int:

Copied from pandas.core.common.count_not_none (not part of the public API)
"""
return sum([arg is not None for arg in args])
return sum(arg is not None for arg in args)
2 changes: 1 addition & 1 deletion xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@ def assert_unique_multiindex_level_names(variables):

duplicate_names = [v for v in level_names.values() if len(v) > 1]
if duplicate_names:
conflict_str = "\n".join([", ".join(v) for v in duplicate_names])
conflict_str = "\n".join(", ".join(v) for v in duplicate_names)
raise ValueError("conflicting MultiIndex level name(s):\n%s" % conflict_str)
# Check confliction between level names and dimensions GH:2299
for k, v in variables.items():
Expand Down