larray.Array.ignore_labels

Array.ignore_labels(axes=None) Array[source]

Ignore labels from axes (replace those axes by “wildcard” axes).

Useful when you want to apply operations between two arrays or subarrays with same shape but incompatible axes (different labels).

Parameters
axesAxis or list/tuple/AxisCollection of Axis, optional

Axis(es) on which you want to drop the labels.

Returns
Array

Notes

Use it at your own risk.

Examples

>>> a = Axis('a=a1,a2')
>>> b = Axis('b=b1,b2')
>>> b2 = Axis('b=b2,b3')
>>> arr1 = ndtest([a, b])
>>> arr1
a\b  b1  b2
 a1   0   1
 a2   2   3
>>> arr1.ignore_labels(b)
a\b*  0  1
  a1  0  1
  a2  2  3
>>> arr1.ignore_labels([a, b])
a*\b*  0  1
    0  0  1
    1  2  3
>>> arr2 = ndtest([a, b2])
>>> arr2
a\b  b2  b3
 a1   0   1
 a2   2   3
>>> arr1 * arr2
Traceback (most recent call last):
...
ValueError: incompatible axes:
Axis(['b2', 'b3'], 'b')
vs
Axis(['b1', 'b2'], 'b')
>>> arr1 * arr2.ignore_labels()
a\b  b1  b2
 a1   0   1
 a2   4   9
>>> arr1.ignore_labels() * arr2
a\b  b2  b3
 a1   0   1
 a2   4   9
>>> arr1.ignore_labels('a') * arr2.ignore_labels('b')
a\b  b1  b2
 a1   0   1
 a2   4   9