From 028e405e8fd8672d0a68d21118305586a34927ad Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 23 Feb 2021 21:24:56 -0500 Subject: [PATCH] eja: simplify to_matrix() for elements. --- mjo/eja/eja_element.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index 7388e96..347aa3c 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -1651,8 +1651,7 @@ class CartesianProductEJAElement(FiniteDimensionalEJAElement): # product spaces, even though they provide a method # with that name. pairs = zip(B, self.to_vector()) - sigma = W.zero() - for (b,alpha) in pairs: - # sum(...) ALSO doesn't work on Cartesian products. - sigma += W(tuple(alpha*b_i for b_i in b)) - return sigma + return sum( ( W(tuple(alpha*b_i for b_i in b)) + for (b,alpha) in pairs ), + W.zero()) + -- 2.44.2