Skip to content

Commit

Permalink
da.store has a compute=False option
Browse files Browse the repository at this point in the history
Returns dsk and keys
  • Loading branch information
mrocklin committed May 10, 2015
1 parent a85ae41 commit b38a866
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dask/array/core.py
Expand Up @@ -491,7 +491,7 @@ def compute(*args, **kwargs):
return results2


def store(sources, targets, **kwargs):
def store(sources, targets, compute=True, **kwargs):
""" Store dask arrays in array-like objects, overwrite data in target
This stores dask arrays into object that supports numpy-style setitem
Expand Down Expand Up @@ -540,7 +540,10 @@ def store(sources, targets, **kwargs):
updates = [insert_to_ooc(tgt, src) for tgt, src in zip(targets, sources)]
dsk = merge([src.dask for src in sources] + updates)
keys = [key for u in updates for key in u]
get(dsk, keys, **kwargs)
if compute:
get(dsk, keys, **kwargs)
else:
return dsk, keys


def blockdims_from_blockshape(shape, blockshape):
Expand Down
3 changes: 3 additions & 0 deletions dask/array/tests/test_array_core.py
Expand Up @@ -619,6 +619,9 @@ def test_store():
assert raises(ValueError, lambda: store(at, at))
assert raises(ValueError, lambda: store([at, bt], [at, bt]))

dsk, keys = store([a, b], [at, bt], compute=False)
assert isinstance(dsk, dict) and isinstance(keys, list)


def test_to_hdf5():
try:
Expand Down

0 comments on commit b38a866

Please sign in to comment.