From a1a85fa8aa448f66b675bb39f6d4371f4efefd25 Mon Sep 17 00:00:00 2001 From: xywei Date: Thu, 29 Aug 2019 09:44:03 -0500 Subject: [PATCH 1/2] Fix node ordering --- modepy/nodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modepy/nodes.py b/modepy/nodes.py index 3ee11fe..776ca60 100644 --- a/modepy/nodes.py +++ b/modepy/nodes.py @@ -298,7 +298,7 @@ def tensor_product_nodes(dims, nodes_1d): nnodes_1d = len(nodes_1d) result = np.empty((dims,) + (nnodes_1d,) * dims) for d in range(dims): - result[-d] = nodes_1d.reshape(*((-1,) + (1,)*d)) + result[-d - 1] = nodes_1d.reshape(*((-1,) + (1,)*d)) return result.reshape(dims, -1) -- GitLab From a9f530ecd1131cfeb10ef51d3d9bda465c507555 Mon Sep 17 00:00:00 2001 From: xywei Date: Thu, 29 Aug 2019 20:37:32 -0500 Subject: [PATCH 2/2] Test that the last axis varies fastest --- test/test_nodes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_nodes.py b/test/test_nodes.py index 7dd2fb9..993785a 100644 --- a/test/test_nodes.py +++ b/test/test_nodes.py @@ -140,6 +140,17 @@ def test_affine_map(): assert la.norm(x-m.inverse(m(x))) < 1e-10 +@pytest.mark.parametrize("dim", [1, 2, 3, 4]) +def test_tensor_product_nodes(dim): + from modepy.nodes import tensor_product_nodes + nnodes = 10 + nodes_1d = np.arange(nnodes) + nodes = tensor_product_nodes(dim, nodes_1d) + assert np.allclose( + nodes[-1], + np.array(nodes_1d.tolist() * nnodes**(dim - 1))) + + # You can test individual routines by typing # $ python test_nodes.py 'test_routine()' -- GitLab