Skip to content

Unexpected nodes ordering of `tensor_product_nodes`

According to its documentation, the returned nodes should be sorted in lexicographical order. However the output of this function is not in such order.

def tensor_product_nodes(dims, nodes_1d):
    """
    :returns: an array of shape ``(dims, nnodes_1d**dims)``. The
        order of nodes is such that the nodes along the last
        axis vary fastest.

    .. versionadded:: 2017.1
Python 3.6.7 | packaged by conda-forge | (default, Jul  2 2019, 02:18:42) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from modepy.nodes import tensor_product_nodes
>>> import numpy as np
>>> tensor_product_nodes(2, np.arange(3))
array([[0., 1., 2., 0., 1., 2., 0., 1., 2.],
       [0., 0., 0., 1., 1., 1., 2., 2., 2.]])
>>> tensor_product_nodes(3, np.arange(3))
array([[0., 1., 2., 0., 1., 2., 0., 1., 2., 0., 1., 2., 0., 1., 2., 0.,
        1., 2., 0., 1., 2., 0., 1., 2., 0., 1., 2.],
       [0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 1.,
        1., 1., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [0., 0., 0., 1., 1., 1., 2., 2., 2., 0., 0., 0., 1., 1., 1., 2.,
        2., 2., 0., 0., 0., 1., 1., 1., 2., 2., 2.]])