Skip to content

Commit 65bb9f9

Browse files
committed
dev
1 parent bff3583 commit 65bb9f9

File tree

1 file changed

+0
-232
lines changed

1 file changed

+0
-232
lines changed

cf/data/data.py

Lines changed: 0 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,6 @@ def __contains__(self, value):
251251

252252
return bool(dx.any())
253253

254-
def __data__(self):
255-
"""Returns a new reference to self."""
256-
return self
257-
258254
def __getitem__(self, indices):
259255
"""Return a subspace of the data defined by indices.
260256
@@ -4376,73 +4372,6 @@ def clip(self, a_min, a_max, units=None, inplace=False, i=False):
43764372
d._set_dask(dx)
43774373
return d
43784374

4379-
@classmethod
4380-
def asdata(cls, d, dtype=None, copy=False):
4381-
"""Convert the input to a `Data` object.
4382-
4383-
If the input *d* has the Data interface (i.e. it has a
4384-
`__data__` method), then the output of this method is used as
4385-
the returned `Data` object. Otherwise, `Data(d)` is returned.
4386-
4387-
:Parameters:
4388-
4389-
d: data-like
4390-
Input data in any form that can be converted to a
4391-
`Data` object. This includes `Data` and `Field`
4392-
objects, and objects with the Data interface, numpy
4393-
arrays and any object which may be converted to a
4394-
numpy array.
4395-
4396-
dtype: data-type, optional
4397-
By default, the data-type is inferred from the input data.
4398-
4399-
copy: `bool`, optional
4400-
If True and *d* has the Data interface, then a copy of
4401-
`d.__data__()` is returned.
4402-
4403-
:Returns:
4404-
4405-
`Data`
4406-
`Data` interpretation of *d*. No copy is performed on the
4407-
input if it is already a `Data` object with matching dtype
4408-
and *copy* is False.
4409-
4410-
**Examples**
4411-
4412-
>>> d = cf.Data([1, 2])
4413-
>>> cf.Data.asdata(d) is d
4414-
True
4415-
>>> d.asdata(d) is d
4416-
True
4417-
4418-
>>> cf.Data.asdata([1, 2])
4419-
<CF Data: [1, 2]>
4420-
4421-
>>> cf.Data.asdata(numpy.array([1, 2]))
4422-
<CF Data: [1, 2]>
4423-
4424-
"""
4425-
data = getattr(d, "__data__", None)
4426-
if data is None:
4427-
# d does not have a Data interface
4428-
data = cls(d)
4429-
if dtype is not None:
4430-
data.dtype = dtype
4431-
4432-
return data
4433-
4434-
# d does have a Data interface
4435-
data = data()
4436-
if copy:
4437-
data = data.copy()
4438-
if dtype is not None and np.dtype(dtype) != data.dtype:
4439-
data.dtype = dtype
4440-
elif dtype is not None and np.dtype(dtype) != data.dtype:
4441-
data = data.copy()
4442-
data.dtype = dtype
4443-
4444-
return data
4445-
44464375
@classmethod
44474376
def arctan2(cls, x1, x2):
44484377
"""Element-wise arc tangent of ``x1/x2`` with correct quadrant.
@@ -7483,167 +7412,6 @@ def trunc(self, inplace=False, i=False):
74837412
d._set_dask(dx)
74847413
return d
74857414

7486-
@classmethod
7487-
def full(
7488-
cls,
7489-
shape,
7490-
fill_value,
7491-
dtype=None,
7492-
units=None,
7493-
calendar=None,
7494-
chunks="auto",
7495-
):
7496-
"""Return a new array of given shape and type, filled with a
7497-
fill value.
7498-
7499-
.. seealso:: `empty`, `ones`, `zeros`
7500-
7501-
:Parameters:
7502-
7503-
shape: `int` or `tuple` of `int`
7504-
The shape of the new array. e.g. ``(2, 3)`` or ``2``.
7505-
7506-
fill_value: scalar
7507-
The fill value.
7508-
7509-
dtype: data-type
7510-
The desired data-type for the array. The default, `None`,
7511-
means ``np.array(fill_value).dtype``.
7512-
7513-
units: `str` or `Units`
7514-
The units for the new data array.
7515-
7516-
calendar: `str`, optional
7517-
The calendar for reference time units.
7518-
7519-
{{chunks: `int`, `tuple`, `dict` or `str`, optional}}
7520-
7521-
.. versionadded:: 3.14.0
7522-
7523-
:Returns:
7524-
7525-
`Data`
7526-
Array of *fill_value* with the given shape and data
7527-
type.
7528-
7529-
**Examples**
7530-
7531-
>>> d = cf.Data.full((2, 3), -99)
7532-
>>> print(d.array)
7533-
[[-99 -99 -99]
7534-
[-99 -99 -99]]
7535-
7536-
>>> d = cf.Data.full(2, 0.0)
7537-
>>> print(d.array)
7538-
[0. 0.]
7539-
7540-
>>> d = cf.Data.full((2,), 0, dtype=bool)
7541-
>>> print(d.array)
7542-
[False False]
7543-
7544-
"""
7545-
if dtype is None:
7546-
# Need to explicitly set the default because dtype is not
7547-
# a named keyword of da.full
7548-
dtype = getattr(fill_value, "dtype", None)
7549-
if dtype is None:
7550-
dtype = np.array(fill_value).dtype
7551-
7552-
dx = da.full(shape, fill_value, dtype=dtype, chunks=chunks)
7553-
return cls(dx, units=units, calendar=calendar)
7554-
7555-
@classmethod
7556-
def ones(cls, shape, dtype=None, units=None, calendar=None, chunks="auto"):
7557-
"""Returns a new array filled with ones of set shape and type.
7558-
7559-
.. seealso:: `empty`, `full`, `zeros`
7560-
7561-
:Parameters:
7562-
7563-
shape: `int` or `tuple` of `int`
7564-
The shape of the new array. e.g. ``(2, 3)`` or ``2``.
7565-
7566-
dtype: data-type
7567-
The desired data-type for the array, e.g.
7568-
`numpy.int8`. The default is `numpy.float64`.
7569-
7570-
units: `str` or `Units`
7571-
The units for the new data array.
7572-
7573-
calendar: `str`, optional
7574-
The calendar for reference time units.
7575-
7576-
{{chunks: `int`, `tuple`, `dict` or `str`, optional}}
7577-
7578-
.. versionadded:: 3.14.0
7579-
7580-
:Returns:
7581-
7582-
`Data`
7583-
Array of ones with the given shape and data type.
7584-
7585-
**Examples**
7586-
7587-
>>> d = cf.Data.ones((2, 3))
7588-
>>> print(d.array)
7589-
[[1. 1. 1.]
7590-
[1. 1. 1.]]
7591-
7592-
>>> d = cf.Data.ones((2,), dtype=bool)
7593-
>>> print(d.array)
7594-
[ True True]
7595-
7596-
"""
7597-
dx = da.ones(shape, dtype=dtype, chunks=chunks)
7598-
return cls(dx, units=units, calendar=calendar)
7599-
7600-
@classmethod
7601-
def zeros(
7602-
cls, shape, dtype=None, units=None, calendar=None, chunks="auto"
7603-
):
7604-
"""Returns a new array filled with zeros of set shape and type.
7605-
7606-
.. seealso:: `empty`, `full`, `ones`
7607-
7608-
:Parameters:
7609-
7610-
shape: `int` or `tuple` of `int`
7611-
The shape of the new array.
7612-
7613-
dtype: data-type
7614-
The data-type of the new array. By default the
7615-
data-type is ``float``.
7616-
7617-
units: `str` or `Units`
7618-
The units for the new data array.
7619-
7620-
calendar: `str`, optional
7621-
The calendar for reference time units.
7622-
7623-
{{chunks: `int`, `tuple`, `dict` or `str`, optional}}
7624-
7625-
.. versionadded:: 3.14.0
7626-
7627-
:Returns:
7628-
7629-
`Data`
7630-
Array of zeros with the given shape and data type.
7631-
7632-
**Examples**
7633-
7634-
>>> d = cf.Data.zeros((2, 3))
7635-
>>> print(d.array)
7636-
[[0. 0. 0.]
7637-
[0. 0. 0.]]
7638-
7639-
>>> d = cf.Data.zeros((2,), dtype=bool)
7640-
>>> print(d.array)
7641-
[False False]
7642-
7643-
"""
7644-
dx = da.zeros(shape, dtype=dtype, chunks=chunks)
7645-
return cls(dx, units=units, calendar=calendar)
7646-
76477415
@_deprecated_kwarg_check("out", version="3.14.0", removed_at="5.0.0")
76487416
@_deprecated_kwarg_check("i", version="3.0.0", removed_at="4.0.0")
76497417
@_inplace_enabled(default=False)

0 commit comments

Comments
 (0)