larray.LArray.expand

LArray.expand(target_axes=None, out=None, readonly=False)[source]

Expands array to target_axes.

Target axes will be added to array if not present. In most cases this function is not needed because LArray can do operations with arrays having different (compatible) axes.

Parameters:

target_axes : list of Axis or AxisCollection, optional

Self can contain axes not present in target_axes. The result axes will be: [self.axes not in target_axes] + target_axes

out : LArray, optional

Output array, must have the correct shape

readonly : bool, optional

Whether returning a readonly view is acceptable or not (this is much faster)

Returns:

LArray

Original array if possible (and out is None).

Examples

>>> a = Axis('a=a1,a2')
>>> b = Axis('b=b1,b2')
>>> arr = ndrange([a, b])
>>> arr
a\b  b1  b2
 a1   0   1
 a2   2   3
>>> c = Axis('c=c1,c2')
>>> arr.expand([a, c, b])
 a  c\b  b1  b2
a1   c1   0   1
a1   c2   0   1
a2   c1   2   3
a2   c2   2   3
>>> arr.expand([b, c])
 a  b\c  c1  c2
a1   b1   0   0
a1   b2   1   1
a2   b1   2   2
a2   b2   3   3