1

When running this code, I have this error :

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)

How can I use the decorator ? It sounds unclear.

tensor
  • 3,088
  • 8
  • 37
  • 71

1 Answers1

0

dv, as written in this first code block (and above), is actually not a DirectView.

from ipyparallel import DirectView as dv
print(type(dv))
<class 'traitlets.traitlets.MetaHasTraits'>

DirectView doesn't need to be imported, instead, it should be created from a Client().

import ipyparallel
client = ipyparallel.Client()
dv = client[:]

print(type(dv))
<class 'ipyparallel.client.view.DirectView'>

Now the decorator will perform as expected. (Although, it looks like you might have to import np_std inside your function or use the require decorator, but that's another question altogether, I recommend working through the examples in the docs to become more familiar)

Kevin
  • 7,960
  • 5
  • 36
  • 57