Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dask: cf.Field.varray #440

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cf/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,10 @@ def Flags(self):
def varray(self):
"""A numpy array view of the data array.

Deprecated at version TODODASKVER. Data are now stored as
`dask` arrays for which, in general, a numpy array view is not
robust.

Changing the elements of the returned view changes the data array.

.. seealso:: `array`, `data`, `datetime_array`
Expand All @@ -4139,8 +4143,16 @@ def varray(self):
<CF Data(5): [999, ... 4] kg m-1 s-2>

"""
self.uncompress(inplace=True)
return super().varray
# self.uncompress(inplace=True)
# return super().varray
_DEPRECATION_ERROR_ATTRIBUTE(
davidhassell marked this conversation as resolved.
Show resolved Hide resolved
self,
"varray",
message="Data are now stored as `dask` arrays for which, "
"in general, a numpy array view is not robust.",
version="TODODASKVER",
removed_at="5.0.0",
) # pragma: no cover

# ----------------------------------------------------------------
# CF properties
Expand Down
38 changes: 8 additions & 30 deletions cf/mixin/propertiesdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2278,27 +2278,6 @@ def array(self):

return data.array

def dask_array(self, copy=True):
"""TODODASKDOCS.

:Parameters:

copy


.. seealso:: `data`, `array`, `datetime_array`

**Examples:**

TODODASKDOCS

"""
data = self.get_data(None)
if data is None:
raise AttributeError(f"{self.__class__.__name__} has no data")

return data.dask_array(copy=copy)

@property
def varray(self):
"""A numpy array view of the data.
Expand All @@ -2325,15 +2304,14 @@ def varray(self):
<CF Data(5): [999, ... 4] kg m-1 s-2>

"""
raise ValueError("TODODASKMSG - deprecated?")

# data = self.get_data(None)
# if data is None:
# raise AttributeError(
# f"{self.__class__.__name__} has no data"
# )
#
# return data.varray
_DEPRECATION_ERROR_ATTRIBUTE(
self,
"varray",
message="Data are now stored as `dask` arrays for which, "
"in general, a numpy array view is not robust.",
version="TODODASKVER",
removed_at="5.0.0",
) # pragma: no cover

@property
def isscalar(self):
Expand Down