diff options
author | Mike Taves <mwtoews@gmail.com> | 2020-01-28 13:12:38 +1300 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-01-27 16:12:38 -0800 |
commit | f398a0df8a2105b2fdeaeab54505451169b0a869 (patch) | |
tree | fe041dbec09eb1a303f7b027cc98e7423476de3f /numpy/lib/function_base.py | |
parent | 6d889e7eca0f7ae6d640c380bd0b604e6530f049 (diff) | |
download | numpy-f398a0df8a2105b2fdeaeab54505451169b0a869.tar.gz |
STY: use 'yield from <expr>' for simple cases (#15444)
This PR uses simple cases of PEP 380 to rewrite:
for v in g:
yield v
into:
yield from <expr>
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 164213bbe..2721b04dd 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -492,8 +492,7 @@ def _piecewise_dispatcher(x, condlist, funclist, *args, **kw): yield x # support the undocumented behavior of allowing scalars if np.iterable(condlist): - for c in condlist: - yield c + yield from condlist @array_function_dispatch(_piecewise_dispatcher) @@ -619,10 +618,8 @@ def piecewise(x, condlist, funclist, *args, **kw): def _select_dispatcher(condlist, choicelist, default=None): - for c in condlist: - yield c - for c in choicelist: - yield c + yield from condlist + yield from choicelist @array_function_dispatch(_select_dispatcher) @@ -767,8 +764,7 @@ def copy(a, order='K'): def _gradient_dispatcher(f, *varargs, axis=None, edge_order=None): yield f - for v in varargs: - yield v + yield from varargs @array_function_dispatch(_gradient_dispatcher) |