From ba952e87821c666ca47fa59b6ed649d405196763 Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
Date: Tue, 7 Jul 2020 15:50:30 -0500
Subject: [PATCH] Add a test for CSEMatVec

---
 sumpy/expansion/__init__.py | 18 +++++++++---------
 sumpy/expansion/pde.py      |  1 +
 test/test_misc.py           | 17 +++++++++++++++++
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/sumpy/expansion/__init__.py b/sumpy/expansion/__init__.py
index 1b3268b5..aa09ddf5 100644
--- a/sumpy/expansion/__init__.py
+++ b/sumpy/expansion/__init__.py
@@ -236,15 +236,15 @@ class CSEMatVec(object):
 
     .. attribute:: assignments
 
-        A list of tuples where the first argument of the tuple
-        is a row and the second argument is a list. If the
-        second argument is empty, the row is equal to the first
-        unused element from the vector. If not, the second
-        argument gives a list of tuples indicating a linear
-        combination of previously calculated row.
-
-        The matrix represented is a square matrix with the number
-        of rows equal to the length of the `assignments` list.
+        A list of lists indicating a linear combination of previously
+        calculated rows. If an element of the `assignments` is empty,
+        then that row is taken from the first unused row from the
+        vector. Each element is a list of tuples where first argument
+        is a previous row number and the second argument is the weight
+        in the linear combination.
+
+        Number of rows in the matrix represented is equal to the
+        length of the `assignments` list.
     """
 
     def __init__(self, assignments):
diff --git a/sumpy/expansion/pde.py b/sumpy/expansion/pde.py
index b61d3a63..5aa93e4d 100644
--- a/sumpy/expansion/pde.py
+++ b/sumpy/expansion/pde.py
@@ -31,6 +31,7 @@ PDE interface
 .. autoclass:: PDE
 """
 
+
 class PDE(object):
     r"""
     Represents a scalar, constant-coefficient PDE of dimension `dim`.
diff --git a/test/test_misc.py b/test/test_misc.py
index d8aff52f..8823d183 100644
--- a/test/test_misc.py
+++ b/test/test_misc.py
@@ -278,6 +278,23 @@ def test_toy_p2e2e2p(ctx_factory, case):
         (conv_factor, case.conv_factor * (1 + RTOL_P2E2E2P))
 
 
+def test_cse_matvec():
+    from sumpy.expansion import CSEMatVec
+    assignments = [[], [(0, 3)], [], [(2, 7), (1, 5)]]
+    op = CSEMatVec(assignments)
+    m = np.array([[1, 0], [3, 0], [0, 1], [15, 7]])
+
+    vec = np.random.random(2)
+    expected_result = m @ vec
+    actual_result = op.matvec(vec, sac=None)
+    assert np.allclose(expected_result, actual_result)
+
+    vec = np.random.random(4)
+    expected_result = m.T @ vec
+    actual_result = op.transpose_matvec(vec, sac=None)
+    assert np.allclose(expected_result, actual_result)
+
+
 # You can test individual routines by typing
 # $ python test_misc.py 'test_p2p(cl.create_some_context)'
 
-- 
GitLab