cfdm.Data.__array__¶
- Data.__array__(dtype=None, copy=None)[source]¶
The numpy array interface.
Added in version (cfdm): 1.7.0
- Parameters:
- dtype: optional
Typecode or data-type to which the array is cast.
- copy:
None
orbool
Included to match the v2
numpy.ndarray.__array__
API, but ignored. The returned numpy array is always independent.Added in version (cfdm): 1.12.0.0
- Returns:
numpy.ndarray
An independent numpy array of the data.
Examples
>>> d = cfdm.Data([1, 2, 3]) >>> a = numpy.array(d) >>> print(type(a)) <class 'numpy.ndarray'> >>> a[0] = -99 >>> d <Data(3): [1, 2, 3]> >>> b = numpy.array(d, float) >>> print(b) [1. 2. 3.]