[IPython-dev] [sympy] sympy in parallel ipython works
Brian Granger
ellisonbg.net@gmail....
Mon Jan 12 11:04:30 CST 2009
Ondrej,
Very nice! And thanks to Reobert Kern for figuring out the problem
with pickling. I will begin playing with this soon.
Cheers,
Brian
On Sun, Jan 11, 2009 at 10:55 PM, Ondrej Certik <ondrej@certik.cz> wrote:
>
> Hi,
>
> thanks to Robert Kern, the pickling problem in protocol 2 in sympy was
> fixed, so sympy seems to be working in ipython parallel. Here is how
> to try it:
>
> Checkout the latest git sympy, go to the sympy root directory (so that
> "import sympy" works), and do:
>
> $ ipcluster -n 4
> Starting controller: Controller PID: 21443
> Starting engines: Engines PIDs: [21449, 21450, 21451, 21452]
> [...]
>
> Leave it running and start ipython in another terminal (in the same dir):
>
> In [1]: from IPython.kernel import client
>
> In [2]: mec = client.MultiEngineClient()
>
> In [3]: mec.get_ids()
> Out[3]: [0, 1, 2, 3]
>
> If this works, then ipython parallel works for you. Then play with sympy:
>
> In [5]: from sympy import var
>
> In [6]: var("x y z")
> Out[6]: (x, y, z)
>
> In [7]: e = (x+y)**5
>
> In [9]: mec.push({"e": e})
> Out[9]: [None, None, None, None]
>
> In [10]: mec.pull("e")
> Out[10]: [(x + y)**5, (x + y)**5, (x + y)**5, (x + y)**5]
>
>
> And do something in parallel:
>
> In [12]: mec.execute("from sympy import *")
> Out[12]:
> <Results List>
> [0] In [4]: from sympy import *
> [1] In [4]: from sympy import *
> [2] In [4]: from sympy import *
> [3] In [4]: from sympy import *
>
> In [19]: mec.execute("var('x y')")
> Out[19]:
> <Results List>
> [0] In [9]: var('x y')
> [1] In [9]: var('x y')
> [2] In [9]: var('x y')
> [3] In [9]: var('x y')
>
> In [17]: mec.scatter("a", range(4))
> Out[17]: [None, None, None, None]
>
> In [18]: mec.execute("print a")
> Out[18]:
> <Results List>
> [0] In [8]: print a
> [0] Out[8]: [0]
>
> [1] In [8]: print a
> [1] Out[8]: [1]
>
> [2] In [8]: print a
> [2] Out[8]: [2]
>
> [3] In [8]: print a
> [3] Out[8]: [3]
>
> In [21]: mec.execute("print expand((x+y)**a[0])")
> Out[21]:
> <Results List>
> [0] In [11]: print expand((x+y)**a[0])
> [0] Out[11]: 1
>
> [1] In [11]: print expand((x+y)**a[0])
> [1] Out[11]: x + y
>
> [2] In [11]: print expand((x+y)**a[0])
> [2] Out[11]: 2*x*y + x**2 + y**2
>
> [3] In [11]: print expand((x+y)**a[0])
> [3] Out[11]: 3*x*y**2 + 3*y*x**2 + x**3 + y**3
>
>
> Brian, now you can finally play with sympy in parallel, it should
> work. Do you have in mind some cool calculation that could be done? :)
>
> Ondrej
>
> P.S. The isympy script isn't working for this, I don't know why, I'll
> try to investigate later.
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sympy@googlegroups.com
> To unsubscribe from this group, send email to sympy+unsubscribe@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>
More information about the IPython-dev
mailing list