Skip to content

Commit

Permalink
chore: Remove unnecessary comprehension (#4026)
Browse files Browse the repository at this point in the history
* chore: Remove unnecessary comprehension

* Update whats-new.rst
  • Loading branch information
pnijhara authored May 5, 2020
1 parent 6ce0724 commit 1b3c768
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
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

0 comments on commit 1b3c768

Please sign in to comment.