cfdm.Data.asdata¶
-
classmethod
Data.
asdata
(d, dtype=None, copy=False)[source]¶ Convert the input to a
Data
object.If the input d has the Data interface (i.e. it has a
__data__
method), then the output of this method is used as the returnedData
object. Otherwise,Data(d)
is returned.New in version (cfdm): 1.11.2.0
- Parameters
- d: data-like
Input data in any form that can be converted to a
Data
object. This includesData
andField
objects, and objects with the Data interface, numpy arrays and any object which may be converted to a numpy array.- dtype: data-type, optional
By default, the data-type is inferred from the input data.
- copy:
bool
, optional If True and d has the Data interface, then a copy of
d.__data__()
is returned.
- Returns
Examples
>>> d = cfdm.Data([1, 2]) >>> cfdm.Data.asdata(d) is d True >>> d.asdata(d) is d True
>>> cfdm.Data.asdata([1, 2]) <Data: [1, 2]>
>>> cfdm.Data.asdata(numpy.array([1, 2])) <Data: [1, 2]>