-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support Dask interface #1674
Support Dask interface #1674
Changes from 2 commits
f65cb52
4b59040
68cddff
5429da1
ffb0ca1
56ec487
f315099
fa968b9
9df0af7
d65569b
bbeafec
ff94d95
a6cde57
79ea37c
c1b8e1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,8 +360,43 @@ def compute(self, **kwargs): | |
-------- | ||
dask.array.compute | ||
""" | ||
new = self.copy(deep=False) | ||
return new.load(**kwargs) | ||
import dask | ||
(result,) = dask.compute(self, **kwargs) | ||
return result | ||
|
||
def visualize(self, **kwargs): | ||
import dask | ||
return dask.visualize(self, **kwargs) | ||
|
||
def __dask_graph__(self): | ||
if isinstance(self._data, dask_array_type): | ||
return self._data.__dask_graph__() | ||
else: | ||
return None | ||
|
||
def __dask_keys__(self): | ||
return self._data.__dask_keys__() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is OK if these methods error (with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we always check if the object is a dask collection first by calling |
||
|
||
@property | ||
def __dask_optimize__(self): | ||
return self._data.__dask_optimize__ | ||
|
||
@property | ||
def __dask_scheduler__(self): | ||
return self._data.__dask_scheduler__ | ||
|
||
def __dask_postcompute__(self): | ||
array_func, array_args = self._data.__dask_postcompute__() | ||
return self._dask_finalize, (array_func, array_args, self._dims, self._attrs, self._encoding) | ||
|
||
def __dask_postpersist__(self): | ||
array_func, array_args = self._data.__dask_postpersist__() | ||
return self._dask_finalize, (array_func, array_args, self._dims, self._attrs, self._encoding) | ||
|
||
@staticmethod | ||
def _dask_finalize(results, array_func, array_args, dims, attrs, encoding): | ||
data = array_func(results, *array_args) | ||
return Variable(dims, data, attrs=attrs, encoding=encoding) | ||
|
||
@property | ||
def values(self): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My inclination would be to leave this out and require using
dask.visualize()
. My concern is that it could be easily confused with.plot()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed