Skip to content

Support dask array conditional in compress#2555

Merged
jcrist merged 2 commits intodask:masterfrom
jcrist:lazy-compress
Jul 25, 2017
Merged

Support dask array conditional in compress#2555
jcrist merged 2 commits intodask:masterfrom
jcrist:lazy-compress

Conversation

@jcrist
Copy link
Copy Markdown
Member

@jcrist jcrist commented Jul 25, 2017

Compress now works with dask arrays as conditionals without calling compute on them. If the conditional is concrete we take an optimized path and return an array of known shape. If it's lazy we return an array of unknown shape along the specified axis.

Supersedes #2548, fixes #2540.

Compress now works with dask arrays as conditionals without calling
compute on them. If the conditional is concrete we take an optimized
path and return an array of known shape. If it's lazy we return an
array of unknown shape along the specified axis.
@jcrist
Copy link
Copy Markdown
Member Author

jcrist commented Jul 25, 2017

cc @jakirkham.

for i in range(a.ndim))]
inds = tuple(range(a.ndim))
out = atop(np.compress, inds, condition, (inds[axis],), a, inds,
axis=axis, dtype=a.dtype)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! Was wondering if this was doable with atop, but was not totally figuring out how.

@jakirkham jakirkham mentioned this pull request Jul 25, 2017
Implements `da.extract` using `da.compress`.
@jcrist
Copy link
Copy Markdown
Member Author

jcrist commented Jul 25, 2017

I also added da.extract since it was quick to do. Supersedes #2546.

@jakirkham jakirkham mentioned this pull request Jul 25, 2017
@jcrist jcrist merged commit 2f1abf8 into dask:master Jul 25, 2017
@jcrist jcrist deleted the lazy-compress branch July 25, 2017 23:04
out = atop(np.compress, inds, condition, (inds[axis],), a, inds,
axis=axis, dtype=a.dtype)
out._chunks = tuple((np.NaN,) * len(c) if i == axis else c
for i, c in enumerate(out.chunks))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow-up, it would be great if there was a formal API for declaring a dimension to be of unknown size.

@sinhrks sinhrks added this to the 0.15.2 milestone Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lazy implementation of compress

3 participants