From c1cfd6c6626f4c4339f21146b8013c68da69ba5d Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
Date: Tue, 7 Jul 2020 10:52:09 -0500
Subject: [PATCH] Use dict, tuple comprehensions. Fix formatting, tuples

---
 sumpy/expansion/local.py | 17 +++++++++--------
 sumpy/expansion/pde.py   |  8 ++++----
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/sumpy/expansion/local.py b/sumpy/expansion/local.py
index 3acdfea0..41e72236 100644
--- a/sumpy/expansion/local.py
+++ b/sumpy/expansion/local.py
@@ -244,12 +244,13 @@ class VolumeTaylorLocalExpansionBase(LocalExpansionBase):
             # of multi-indices needed is much less than
             # gnitstam(src_order + tgt order) when PDE conforming expansions
             # are used. For full Taylor, there's no difference.
-            max_mi = [0]*self.dim
-            for i in range(self.dim):
-                max_mi[i] = max(mi[i] for mi in
-                                  src_expansion.get_coefficient_identifiers())
-                max_mi[i] += max(mi[i] for mi in
-                                  self.get_coefficient_identifiers())
+
+            def calc_max_mi(mis):
+                return (max(mi[i] for mi in mis) for i in range(self.dim))
+
+            src_max_mi = calc_max_mi(src_expansion.get_coefficient_identifiers())
+            tgt_max_mi = calc_max_mi(self.get_coefficient_identifiers())
+            max_mi = add_mi(src_max_mi, tgt_max_mi)
 
             # Create a expansion terms wrangler for derivatives up to order
             # (tgt order)+(src order) including a corresponding reduction matrix
@@ -261,8 +262,8 @@ class VolumeTaylorLocalExpansionBase(LocalExpansionBase):
             tgtplusderiv_full_coeff_ids = \
                 tgtplusderiv_exp_terms_wrangler.get_full_coefficient_identifiers()
 
-            tgtplusderiv_ident_to_index = dict((ident, i) for i, ident in
-                                enumerate(tgtplusderiv_full_coeff_ids))
+            tgtplusderiv_ident_to_index = {ident: i for i, ident in
+                                enumerate(tgtplusderiv_full_coeff_ids)}
 
             result = []
             for lexp_mi in self.get_coefficient_identifiers():
diff --git a/sumpy/expansion/pde.py b/sumpy/expansion/pde.py
index e0b0b7c8..34f95cb2 100644
--- a/sumpy/expansion/pde.py
+++ b/sumpy/expansion/pde.py
@@ -27,9 +27,9 @@ from sumpy.tools import add_mi
 
 class PDE(object):
     r"""
-    Represents a scalar, constant-coefficient PDE of dimension `dim`. It is represented by a
-    dictionary. The dictionary maps a multi-index given as a tuple
-    to the coefficient. This object is immutable.
+    Represents a scalar, constant-coefficient PDE of dimension `dim`.
+    It is represented by a dictionary. The dictionary maps a multi-index
+    given as a tuple to the coefficient. This object is immutable.
     """
     def __init__(self, dim, eq):
         """
@@ -51,7 +51,7 @@ class PDE(object):
         assert self.dim == other_pde.dim
         res = self.eq.copy()
         for k, v in other_pde.eq.items():
-            if k in res.eq:
+            if k in res:
                 res[k] += v
             else:
                 res[k] = v
-- 
GitLab