larray.ndtest
- larray.ndtest(shape_or_axes, start=0, label_start=0, title=None, dtype=<class 'int'>, meta=None) Array [source]
Return test array with given shape.
Axes are named by single letters starting from ‘a’. Axes labels are constructed using a ‘{axis_name}{label_pos}’ pattern (e.g. ‘a0’). Values start from start increase by steps of 1.
- Parameters
- shape_or_axesint, tuple/list of int, str, single axis or tuple/list/AxisCollection of axes
If int or tuple/list of int, represents the shape of the array to create. In that case, default axes are generated. If string, it is used to generate axes (see
AxisCollection
constructor).- startint or float, optional
Start value
- label_startint, optional
Label index for each axis is label_start + position. label_start defaults to 0.
- titlestr, optional
Deprecated. See ‘meta’ below.
- dtypetype or np.dtype, optional
Type of resulting array.
- metalist of pairs or dict or Metadata, optional
Metadata (title, description, author, creation_date, …) associated with the array. Keys must be strings. Values must be of type string, int, float, date, time or datetime.
- Returns
- Array
Examples
Create test array by passing a shape
>>> ndtest(6) a a0 a1 a2 a3 a4 a5 0 1 2 3 4 5 >>> ndtest((2, 3)) a\b b0 b1 b2 a0 0 1 2 a1 3 4 5 >>> ndtest((2, 3), label_start=1) a\b b1 b2 b3 a1 0 1 2 a2 3 4 5 >>> ndtest((2, 3), start=2) a\b b0 b1 b2 a0 2 3 4 a1 5 6 7 >>> ndtest((2, 3), dtype=float) a\b b0 b1 b2 a0 0.0 1.0 2.0 a1 3.0 4.0 5.0
Create test array by passing axes
>>> ndtest("nat=BE,FO;sex=M,F") nat\sex M F BE 0 1 FO 2 3 >>> nat = Axis("nat=BE,FO") >>> sex = Axis("sex=M,F") >>> ndtest([nat, sex]) nat\sex M F BE 0 1 FO 2 3