Using dask.compute with an array of delayed items


Using dask.compute with an array of delayed items



Currently, I can create (nested) lists of objects that are a mix of eagerly computed items and delayed items.



If I pass that list to dask.compute, it can create the graph and computes the result as a new list replacing the delayed items with their computed counterparts.


dask.compute



The list has a very well defined structure that I would like to exploit. As such, before using Dask, I had been using numpy array with dtype=object.


dtype=object



Can I pass these numpy arrays to dask.compute?
Are there other collections, that support ND slicing à la numpy, that I can use instead?


dask.compute



My current workaround is to either use dictionaries, or nested lists, but the ability to slice numpy arrays is really nice and I would not like to loose that.



Thanks,



Mark



code example as notebook




1 Answer
1



Dask.compute currently only searches through core Python data structures like lists and dictionaries. It does not search through Numpy arrays.



You might consider using Numpy arrays until the very end, then calling .tolist() then calling np.array again.


.tolist()



result = dask.compute(*x.tolist())
result = np.array(result)





great thanks, that was my workaround too, I just wanted to make sure I wasn't missing something.
– hmaarrfk
Jun 29 at 22:44





Do you have any plans to support numpy arrays in your nested packing and unpacking?
– hmaarrfk
Jun 29 at 23:17





Me personally? No I don't plan to work on this. If you are curious about the project then you should raise an issue.
– MRocklin
Jun 30 at 0:51





you included the dask team. I'll raise an issue on github. Thanks
– hmaarrfk
Jun 30 at 1:38






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift