larray.AxisCollection.get

AxisCollection.get(self, key, default=None, name=None)[source]

Returns axis corresponding to key. If not found, the argument name is used to create a new Axis. If name is None, the default axis is then returned.

Parameters:
key : key

Key corresponding to an axis of the current AxisCollection.

default : axis, optional

Default axis to return if key doesn’t correspond to any axis of the collection and argument name is None.

name : str, optional

If key doesn’t correspond to any axis of the collection, a new Axis with this name is created and returned.

Examples

>>> age = Axis(range(20), 'age')
>>> sex = Axis('sex=M,F')
>>> time = Axis([2007, 2008, 2009, 2010], 'time')
>>> col = AxisCollection([age, time])
>>> col.get('time')
Axis([2007, 2008, 2009, 2010], 'time')
>>> col.get('sex', sex)
Axis(['M', 'F'], 'sex')
>>> col.get('nb_children', None, 'nb_children')
Axis(1, 'nb_children')