diff --git a/modepy/nodes.py b/modepy/nodes.py index 3ee11feb7f39ff7bac99445e5006c1a0d36778c4..776ca605b0766876fd1b8c9a9ccaf62f168588fa 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) diff --git a/test/test_nodes.py b/test/test_nodes.py index 7dd2fb9f5cb165feef087f177da348fbc2df3802..993785a9c62684c5641c52cfec5670bd50f31240 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()'