larray.Session.get

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

Returns the object corresponding to the key. If the key doesn’t correspond to any object, a default one can be returned.

Parameters:
key : str

Name of the object.

default : object, optional

Returned object if the key doesn’t correspond to any object of the current session.

Returns:
object

Object corresponding to the given key or a default one if not found.

Examples

>>> # axes
>>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2")
>>> # groups
>>> a01 = a['a0,a1'] >> 'a01'
>>> # arrays
>>> arr1, arr2 = ndtest((a, b)), ndtest(a)
>>> s = Session([('a', a), ('b', b), ('a01', a01), ('arr1', arr1), ('arr2', arr2)])
>>> arr = s.get('arr1')
>>> arr
a\b  b0  b1  b2
 a0   0   1   2
 a1   3   4   5
 a2   6   7   8
>>> arr = s.get('arr4', zeros('a=a0,a1;b=b0,b1', dtype=int))
>>> arr
a\b  b0  b1
 a0   0   0
 a1   0   0