larray.ndrange

larray.ndrange(axes, start=0, title='', dtype=<class 'int'>)[source]

Returns an array with the specified axes and filled with increasing int.

Parameters:

axes : single axis or tuple/list/AxisCollection of axes

Axes of the array to create. Each axis can be given as either:

  • Axis object: actual axis object to use.
  • single int: length of axis. will create a wildcard axis of that length.
  • str: coma separated list of labels, with optional leading ‘=’ to set the name of the axis.
    eg. “a,b,c” or “sex=F,M”
  • (labels, name) pair: name and labels of axis

start : number, optional

title : str, optional

Title.

dtype : dtype, optional

The type of the output array. Defaults to int.

Returns:

LArray

Examples

>>> nat = Axis('nat=BE,FO')
>>> sex = Axis('sex=M,F')
>>> ndrange([nat, sex])
nat\sex  M  F
     BE  0  1
     FO  2  3
>>> ndrange(['nat=BE,FO', 'sex=M,F'])
nat\sex  M  F
     BE  0  1
     FO  2  3
>>> ndrange([(['BE', 'FO'], 'nat'),
...          (['M', 'F'], 'sex')])
nat\sex  M  F
     BE  0  1
     FO  2  3
>>> ndrange([('BE,FO', 'nat'),
...          ('M,F', 'sex')])
nat\sex  M  F
     BE  0  1
     FO  2  3
>>> ndrange('nat=BE,FO;sex=M,F')
nat\sex  M  F
     BE  0  1
     FO  2  3
>>> ndrange([2, 3], dtype=float)
{0}*\{1}*    0    1    2
        0  0.0  1.0  2.0
        1  3.0  4.0  5.0
>>> ndrange(3, start=2)
{0}*  0  1  2
      2  3  4
>>> ndrange('a,b,c')
{0}  a  b  c
     0  1  2