@@ -267,10 +267,6 @@ def __contains__(self, value):
267
267
268
268
return bool (dx .any ())
269
269
270
- def __data__ (self ):
271
- """Returns a new reference to self."""
272
- return self
273
-
274
270
def __getitem__ (self , indices ):
275
271
"""Return a subspace of the data defined by indices.
276
272
@@ -4784,73 +4780,6 @@ def clip(self, a_min, a_max, units=None, inplace=False, i=False):
4784
4780
d ._set_dask (dx )
4785
4781
return d
4786
4782
4787
- @classmethod
4788
- def asdata (cls , d , dtype = None , copy = False ):
4789
- """Convert the input to a `Data` object.
4790
-
4791
- If the input *d* has the Data interface (i.e. it has a
4792
- `__data__` method), then the output of this method is used as
4793
- the returned `Data` object. Otherwise, `Data(d)` is returned.
4794
-
4795
- :Parameters:
4796
-
4797
- d: data-like
4798
- Input data in any form that can be converted to a
4799
- `Data` object. This includes `Data` and `Field`
4800
- objects, and objects with the Data interface, numpy
4801
- arrays and any object which may be converted to a
4802
- numpy array.
4803
-
4804
- dtype: data-type, optional
4805
- By default, the data-type is inferred from the input data.
4806
-
4807
- copy: `bool`, optional
4808
- If True and *d* has the Data interface, then a copy of
4809
- `d.__data__()` is returned.
4810
-
4811
- :Returns:
4812
-
4813
- `Data`
4814
- `Data` interpretation of *d*. No copy is performed on the
4815
- input if it is already a `Data` object with matching dtype
4816
- and *copy* is False.
4817
-
4818
- **Examples**
4819
-
4820
- >>> d = cf.Data([1, 2])
4821
- >>> cf.Data.asdata(d) is d
4822
- True
4823
- >>> d.asdata(d) is d
4824
- True
4825
-
4826
- >>> cf.Data.asdata([1, 2])
4827
- <CF Data: [1, 2]>
4828
-
4829
- >>> cf.Data.asdata(numpy.array([1, 2]))
4830
- <CF Data: [1, 2]>
4831
-
4832
- """
4833
- data = getattr (d , "__data__" , None )
4834
- if data is None :
4835
- # d does not have a Data interface
4836
- data = cls (d )
4837
- if dtype is not None :
4838
- data .dtype = dtype
4839
-
4840
- return data
4841
-
4842
- # d does have a Data interface
4843
- data = data ()
4844
- if copy :
4845
- data = data .copy ()
4846
- if dtype is not None and np .dtype (dtype ) != data .dtype :
4847
- data .dtype = dtype
4848
- elif dtype is not None and np .dtype (dtype ) != data .dtype :
4849
- data = data .copy ()
4850
- data .dtype = dtype
4851
-
4852
- return data
4853
-
4854
4783
@classmethod
4855
4784
def arctan2 (cls , x1 , x2 ):
4856
4785
"""Element-wise arc tangent of ``x1/x2`` with correct quadrant.
@@ -7978,167 +7907,6 @@ def trunc(self, inplace=False, i=False):
7978
7907
d ._set_dask (dx )
7979
7908
return d
7980
7909
7981
- @classmethod
7982
- def full (
7983
- cls ,
7984
- shape ,
7985
- fill_value ,
7986
- dtype = None ,
7987
- units = None ,
7988
- calendar = None ,
7989
- chunks = "auto" ,
7990
- ):
7991
- """Return a new array of given shape and type, filled with a
7992
- fill value.
7993
-
7994
- .. seealso:: `empty`, `ones`, `zeros`
7995
-
7996
- :Parameters:
7997
-
7998
- shape: `int` or `tuple` of `int`
7999
- The shape of the new array. e.g. ``(2, 3)`` or ``2``.
8000
-
8001
- fill_value: scalar
8002
- The fill value.
8003
-
8004
- dtype: data-type
8005
- The desired data-type for the array. The default, `None`,
8006
- means ``np.array(fill_value).dtype``.
8007
-
8008
- units: `str` or `Units`
8009
- The units for the new data array.
8010
-
8011
- calendar: `str`, optional
8012
- The calendar for reference time units.
8013
-
8014
- {{chunks: `int`, `tuple`, `dict` or `str`, optional}}
8015
-
8016
- .. versionadded:: 3.14.0
8017
-
8018
- :Returns:
8019
-
8020
- `Data`
8021
- Array of *fill_value* with the given shape and data
8022
- type.
8023
-
8024
- **Examples**
8025
-
8026
- >>> d = cf.Data.full((2, 3), -99)
8027
- >>> print(d.array)
8028
- [[-99 -99 -99]
8029
- [-99 -99 -99]]
8030
-
8031
- >>> d = cf.Data.full(2, 0.0)
8032
- >>> print(d.array)
8033
- [0. 0.]
8034
-
8035
- >>> d = cf.Data.full((2,), 0, dtype=bool)
8036
- >>> print(d.array)
8037
- [False False]
8038
-
8039
- """
8040
- if dtype is None :
8041
- # Need to explicitly set the default because dtype is not
8042
- # a named keyword of da.full
8043
- dtype = getattr (fill_value , "dtype" , None )
8044
- if dtype is None :
8045
- dtype = np .array (fill_value ).dtype
8046
-
8047
- dx = da .full (shape , fill_value , dtype = dtype , chunks = chunks )
8048
- return cls (dx , units = units , calendar = calendar )
8049
-
8050
- @classmethod
8051
- def ones (cls , shape , dtype = None , units = None , calendar = None , chunks = "auto" ):
8052
- """Returns a new array filled with ones of set shape and type.
8053
-
8054
- .. seealso:: `empty`, `full`, `zeros`
8055
-
8056
- :Parameters:
8057
-
8058
- shape: `int` or `tuple` of `int`
8059
- The shape of the new array. e.g. ``(2, 3)`` or ``2``.
8060
-
8061
- dtype: data-type
8062
- The desired data-type for the array, e.g.
8063
- `numpy.int8`. The default is `numpy.float64`.
8064
-
8065
- units: `str` or `Units`
8066
- The units for the new data array.
8067
-
8068
- calendar: `str`, optional
8069
- The calendar for reference time units.
8070
-
8071
- {{chunks: `int`, `tuple`, `dict` or `str`, optional}}
8072
-
8073
- .. versionadded:: 3.14.0
8074
-
8075
- :Returns:
8076
-
8077
- `Data`
8078
- Array of ones with the given shape and data type.
8079
-
8080
- **Examples**
8081
-
8082
- >>> d = cf.Data.ones((2, 3))
8083
- >>> print(d.array)
8084
- [[1. 1. 1.]
8085
- [1. 1. 1.]]
8086
-
8087
- >>> d = cf.Data.ones((2,), dtype=bool)
8088
- >>> print(d.array)
8089
- [ True True]
8090
-
8091
- """
8092
- dx = da .ones (shape , dtype = dtype , chunks = chunks )
8093
- return cls (dx , units = units , calendar = calendar )
8094
-
8095
- @classmethod
8096
- def zeros (
8097
- cls , shape , dtype = None , units = None , calendar = None , chunks = "auto"
8098
- ):
8099
- """Returns a new array filled with zeros of set shape and type.
8100
-
8101
- .. seealso:: `empty`, `full`, `ones`
8102
-
8103
- :Parameters:
8104
-
8105
- shape: `int` or `tuple` of `int`
8106
- The shape of the new array.
8107
-
8108
- dtype: data-type
8109
- The data-type of the new array. By default the
8110
- data-type is ``float``.
8111
-
8112
- units: `str` or `Units`
8113
- The units for the new data array.
8114
-
8115
- calendar: `str`, optional
8116
- The calendar for reference time units.
8117
-
8118
- {{chunks: `int`, `tuple`, `dict` or `str`, optional}}
8119
-
8120
- .. versionadded:: 3.14.0
8121
-
8122
- :Returns:
8123
-
8124
- `Data`
8125
- Array of zeros with the given shape and data type.
8126
-
8127
- **Examples**
8128
-
8129
- >>> d = cf.Data.zeros((2, 3))
8130
- >>> print(d.array)
8131
- [[0. 0. 0.]
8132
- [0. 0. 0.]]
8133
-
8134
- >>> d = cf.Data.zeros((2,), dtype=bool)
8135
- >>> print(d.array)
8136
- [False False]
8137
-
8138
- """
8139
- dx = da .zeros (shape , dtype = dtype , chunks = chunks )
8140
- return cls (dx , units = units , calendar = calendar )
8141
-
8142
7910
@_deprecated_kwarg_check ("out" , version = "3.14.0" , removed_at = "5.0.0" )
8143
7911
@_deprecated_kwarg_check ("i" , version = "3.0.0" , removed_at = "4.0.0" )
8144
7912
@_inplace_enabled (default = False )
0 commit comments