[英]Force a Dask Delayed object to compute all parameters before applying the function
我真的很喜歡使用Dask。
有沒有辦法可以強制延遲對象在應用延遲函數之前要求計算所有它的參數?
簡單的例子(用例對集合更有趣):
def inc(x, y):
return x + y
dinc = dask.delayed(inc, pure=True)
喜歡的東西
def inc(x, y):
if hasattr(x, compute):
x = x.compute()
if hasattr(y, compute):
y = y.compute()
return x + y
dinc = dask.delayed(inc, pure=True)
這樣,函數將根據reduce模式起作用。 謝謝!
Dask.delayed會自動執行此操作。 在進入延遲函數之前,將計算任何delayed
對象或dask集合(數組,數據幀,包)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.