Skip to content

Commit

Permalink
support backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Nov 1, 2017
1 parent ffb0ca1 commit 91edf8b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
10 changes: 4 additions & 6 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,8 @@ def compute(self, **kwargs):
--------
dask.array.compute
"""
import dask
(result,) = dask.compute(self, **kwargs)
return result
new = self.copy(deep=False)
return new.load(**kwargs)

def persist(self, **kwargs):
""" Trigger computation in constituent dask arrays
Expand All @@ -666,9 +665,8 @@ def persist(self, **kwargs):
--------
dask.persist
"""
import dask
(result,) = dask.persist(self, **kwargs)
return result
ds = self._to_temp_dataset().persist(**kwargs)
return self._from_temp_dataset(ds)

def copy(self, deep=True):
"""Returns a copy of this array.
Expand Down
5 changes: 2 additions & 3 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,8 @@ def persist(self, **kwargs):
--------
dask.persist
"""
import dask
(result,) = dask.persist(self, **kwargs)
return result
new = self.copy(deep=False)
return new._persist_inplace(**kwargs)

@classmethod
def _construct_direct(cls, variables, coord_names, dims=None, attrs=None,
Expand Down
5 changes: 2 additions & 3 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,8 @@ def compute(self, **kwargs):
--------
dask.array.compute
"""
import dask
(result,) = dask.compute(self, **kwargs)
return result
new = self.copy(deep=False)
return new.load(**kwargs)

def __dask_graph__(self):
if isinstance(self._data, dask_array_type):
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_dask_distributed_integration_test(loop, engine):
assert_allclose(original, computed)


@pytest.mark.skipif(distributed.__version__ <= '1.19.3')
@gen_cluster(client=True, timeout=None)
def test_async(c, s, a, b):
x = create_test_data()
Expand Down Expand Up @@ -63,5 +64,4 @@ def test_async(c, s, a, b):
assert not dask.is_dask_collection(w)
assert_allclose(x + 10, w)


assert s.task_state

0 comments on commit 91edf8b

Please sign in to comment.