Ipython IPY与directview并行错误
运行此代码时,出现以下错误:Ipython IPY与directview并行错误,ipython,ipython-parallel,Ipython,Ipython Parallel,运行此代码时,出现以下错误: from ipyparallel import error, AsyncHubResult, DirectView as dv, Reference @dv.parallel(block=True) def np_std_par(x): return np_std(x) TypeError: unbound method parallel() must be called with DirectView instance as first argume
from ipyparallel import error, AsyncHubResult, DirectView as dv, Reference
@dv.parallel(block=True)
def np_std_par(x):
return np_std(x)
TypeError: unbound method parallel() must be called with
DirectView instance as first argument (got nothing instead)
我如何使用装饰器?
听起来不清楚。
dv
,正如在第一个代码块(及以上)中所写的,实际上不是DirectView
从ipyparallel导入DirectView作为dv
打印(类型(dv))
DirectView
不需要导入,而是
import-ipyparallel
client=ipyparallel.client()
dv=客户端[:]
打印(类型(dv))
现在,装饰器将按预期执行。(虽然,看起来您可能必须在函数中导入
np_std
,或者使用require
装饰器,但这完全是另一个问题,我建议您仔细阅读文档中的示例,以便更加熟悉)dv
,如第一个代码块(及以上)中所述,实际上不是DirectView
从ipyparallel导入DirectView作为dv
打印(类型(dv))
DirectView
不需要导入,而是
import-ipyparallel
client=ipyparallel.client()
dv=客户端[:]
打印(类型(dv))
现在,装饰器将按预期执行。(虽然看起来您可能需要在函数中导入np_std
,或者使用require
装饰器,但这完全是另一个问题,我建议您仔细阅读文档中的示例,以便更加熟悉)