python - How to use IPython.parallel for functions with multiple inputs? -


This is my first attempt to use IPython.parallel , so please support me Take it.

I read this question and are having trouble implementing a simple example in this way:

  import gmpy2 as GM import IMIthon from np Import as Parallel Import Client RC = Client) Lview = rc.load_balanced_view () lview.block = True a = 1 def L2 (ii, jj): Out = [] out.append (gm.fac (ii + jj + a)) Nloop I have problems:  

    a is defined outside of the loop and I think I need to do something like "push" but it is getting a bit confusing. Do I need to "pull" later?

  1. There are two arguments required for the function and I do not know how to pass them correctly I tried things like zip (ii, jj) but some errors were found. .
  2. In addition to this, I believe the fact that I should not affect a random library gmpy2 things are correct? Do I need to do something special for this?

Ideally I would like your help so that this simple example runs the error code free of charge.

If you think it's beneficial to post my unsuccessful effort at # 2, tell me I'm in the dark with # 1.

I find two ways that this works:

Code> push is inserting the core into the variable There is no need to drag it, the variable will be defined only in the namespace of each process-engine.

  rc.client [:]. Push ({'a': a}) R2 = lview.map (L2, Ii, jj)  

Otherwise, L2 to a Take as an input and <<> code function:

  def L2 (ii, jj, a): out = [] out A  FAC for .append (ii + jj + a) returns R2 = lview.map (L2, ii, jj, [a] * nloop)  

According to this website regarding import: You import the necessary library in the function:

Note the import inside the function. This is a normal model, to ensure that the appropriate modules are imported where the work is going on. You can manually import the module's name of the engine (views) through view.execute ('import numerical') ().

Or you can do this according to the link


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -