Add the @ operator to the delayed objects#3691
Conversation
7b885ff to
4c4f9e5
Compare
4c4f9e5 to
e8a65c5
Compare
dask/tests/test_delayed.py
Outdated
| c = delayed(dummy()) | ||
| d = delayed(dummy()) | ||
|
|
||
| assert (c @ d).compute() == 4 |
There was a problem hiding this comment.
If this causes a SyntaxError in Python 2 (seems likely) then we might wrap this in a string and then call eval like the following:
In [1]: x = 1
In [2]: eval('x + x')
Out[2]: 2There was a problem hiding this comment.
Hmm, you are right. Ok, let me try again
https://travis-ci.org/dask/dask/jobs/398449158#L1338
There was a problem hiding this comment.
FWIW we've since changed our doctests to Python 3. ( #3744 )
2408001 to
dc37be0
Compare
|
Is there a reason against iterating through |
|
I'll have to defer to @jcrist for that question.
…On Fri, Jun 29, 2018 at 8:05 PM, Mark Harfouche ***@***.***> wrote:
Is there a reason against iterating through operator.__all__ and simply
adding all of those functions to delayed objects?
import operator
for i in operator.__all__:
print(getattr(operator, i))
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3691 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszN5YbHAv1EDNlKXMim-R-YNZ8ab6ks5uBsDegaJpZM4U9skN>
.
|
We only want to support operators that can validly be delayed (e.g. PR looks good, thanks! Merging. |
|
Thanks @hmaarrfk :) |
|
No, thank you three, I was able to quite quickly (well after a bunch of refractoring) speedup my code quite s ignificantly using dask, I never use them, but is there a reason not to support operators like |
These work automatically in python for things that don't mutate the object inplace. They work fine for delayed objects: In [1]: from dask import delayed
In [2]: a = delayed(1)
In [3]: a
Out[3]: Delayed('int-d1948b47-8998-4fbf-b52b-b5989688996c')
In [4]: a += 2
In [5]: a.compute()
Out[5]: 3 |
|
@jcrist clearly I never tried it. Python does a lot of magic sometimes ;) |
….com/convexset/dask into fix-tsqr-case-chunk-with-zero-height * 'fix-tsqr-case-chunk-with-zero-height' of https://github.com/convexset/dask: fixed typo in documentation and improved clarity Implement .blocks accessor (dask#3689) Fix wrong names (dask#3695) Adds endpoint and retstep support for linspace (dask#3675) Add the @ operator to the delayed objects (dask#3691) Align auto chunks to provided chunks, rather than shape (dask#3679) Adds quotes to source pip install (dask#3678) Prefer end-tasks with low numbers of dependencies when ordering (dask#3588) Reimplement argtopk to release the GIL (dask#3610) Note `da.pad` can be used with `map_overlap` (dask#3672) Allow tasks back onto ordering stack if they have one dependency (dask#3652) Fix extra progressbar (dask#3669) Break apart uneven array-of-int slicing to separate chunks (dask#3648) fix for `dask.array.linalg.tsqr` fails tests (intermittently) with arrays of uncertain dimensions (dask#3662)
|
|
||
|
|
||
| if PY3: | ||
| Delayed._bind_operator(operator.matmul) |
There was a problem hiding this comment.
Guess we forgot about Python 3.4 (myself included). Put up a tweak in PR ( #3791 ), which should allow this to work on Python 3.4 as well.
|
I think the test needs to be tweeted as well in this case.
…On Fri, Jul 20, 2018 at 12:31 PM jakirkham ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In dask/delayed.py
<#3691 (comment)>:
> @@ -520,6 +520,10 @@ def __call__(self, *args, **kwargs):
Delayed._bind_operator(op)
+if PY3:
+ Delayed._bind_operator(operator.matmul)
Guess we forgot about Python 3.4 (myself included). Put up a tweak in PR (
#3791 <#3791> ), which should allow this
to work on Python 3.4 as well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3691 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFfmLjYB6rLhpjkmbRHd0XGPz2NDXZ3ks5uIgXUgaJpZM4U9skN>
.
|
|
Good point. Thanks. Missed that. |
not sure if this passes for python 2, but here goes.
flake8 dask