larray.Session.get

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

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

Parameters:

key : str

Name of the array.

default : array, optional

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

Returns:

LArray

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

Examples

>>> arr1, arr2, arr3 = ndtest((2, 2)), ndtest(4), ndtest((3, 2))
>>> s = Session([('arr1', arr1), ('arr2', arr2), ('arr3', arr3)])
>>> arr = s.get('arr1')
>>> arr
a\b  b0  b1
 a0   0   1
 a1   2   3
>>> arr = s.get('arr4', zeros('a=a0,a1;b=b0,b1', dtype=int))
>>> arr
a\b  b0  b1
 a0   0   0
 a1   0   0