diff options
author | Roman Yurchak <rth.yurchak@pm.me> | 2018-12-01 19:03:55 +0100 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2018-12-01 10:03:55 -0800 |
commit | 0ee245bc6df60b911fafe81a743ec2a68a063c20 (patch) | |
tree | 4b32a0091c206d64ceda3f51ea134661dcaff513 /numpy/core/einsumfunc.py | |
parent | 69addfdfeee4226f723bb1f8d6f583221725319a (diff) | |
download | numpy-0ee245bc6df60b911fafe81a743ec2a68a063c20.tar.gz |
MAINT: Use list and dict comprehension when possible (#12445)
* Use list comprehension
* More list comprehension migration
* Revert key copying in dict
* A few more fixes
* More reverts
* Use dict comprehension
* Fix dict comprehension
* Address review comments
* More review comments
* Fix for empty unpacking of zip(*
* Revert zip(* unpacking altogether
* Fix dict copying
* More simplifications
Diffstat (limited to 'numpy/core/einsumfunc.py')
-rw-r--r-- | numpy/core/einsumfunc.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/numpy/core/einsumfunc.py b/numpy/core/einsumfunc.py index d9f88cb1c..963c696ae 100644 --- a/numpy/core/einsumfunc.py +++ b/numpy/core/einsumfunc.py @@ -888,9 +888,8 @@ def einsum_path(*operands, **kwargs): broadcast_indices = [set(x) for x in broadcast_indices] # Compute size of each input array plus the output array - size_list = [] - for term in input_list + [output_subscript]: - size_list.append(_compute_size_by_dict(term, dimension_dict)) + size_list = [_compute_size_by_dict(term, dimension_dict) + for term in input_list + [output_subscript]] max_size = max(size_list) if memory_limit is None: @@ -1375,9 +1374,7 @@ def einsum(*operands, **kwargs): # Start contraction loop for num, contraction in enumerate(contraction_list): inds, idx_rm, einsum_str, remaining, blas = contraction - tmp_operands = [] - for x in inds: - tmp_operands.append(operands.pop(x)) + tmp_operands = [operands.pop(x) for x in inds] # Do we need to deal with the output? handle_out = specified_out and ((num + 1) == len(contraction_list)) |