cf.Data.last_element

Data.last_element()[source]

Return the last element of the data as a scalar.

Performance

If possible, a cached value is returned. Otherwise the delayed operations needed to compute the element are executed, and cached for subsequent calls.

Returns

The last element of the data.

Examples

>>> d = cf.Data(9.0)
>>> x = d.last_element()
>>> print(x, type(x))
9.0 <class 'float'>
>>> d = cf.Data([[1, 2], [3, 4]])
>>> x = d.last_element()
>>> print(x, type(x))
4 <class 'int'>
>>> d[-1, -1] = cf.masked
>>> y = d.last_element()
>>> print(y, type(y))
-- <class 'numpy.ma.core.MaskedConstant'>
>>> d = cf.Data(['foo', 'bar'])
>>> x = d.last_element()
>>> print(x, type(x))
bar <class 'str'>