Hi Ondrej, I've tried to figure out exactly where the errors lies, but don't have anything concrete. Here's what I have come up with:
> >> y=Symbol("pow(A,2)") > >> Poly(y,y) Poly(pow(A,2), pow(A,2)) Seems OK. > >> x=sympify("pow1(PZPZ)") > >> help(x) Help on pow1 in module sympy.core.function object: class pow1(Function) | Base class for applied functions. | Constructor of undefined classes. | | Method resolution order: | pow1 | Function | sympy.core.basic.Basic | sympy.core.assumptions.AssumeMeths | __builtin__.object <snip> > >> Poly(x,x) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/data/ncsg3/pythonModules/lib/python2.5/site-packages/ sympy-0.6.4-py2.5.egg/sympy/polys/polynomial.py", line 310, in __new__ raise SymbolsError("Invalid symbols: %s" % (symbols,)) sympy.polys.polynomial.SymbolsError: Invalid symbols: (pow1(PZPZ),) Notice that I've used 'pow1' not 'pow'. I think that sympify creates a function 'pow1' that Poly doesn't know what to do with. When we change pow1 -> pow we get the same error, so essentially I think that pow isn't being associated with power. HTH, Colin On Apr 30, 5:05 pm, Ondrej Certik <ond...@certik.cz> wrote: > On Thu, Apr 30, 2009 at 3:01 AM, Colin Gillespie <c.gilles...@ncl.ac.uk> wrote: > > > Hi, > > > In the code: > > >>>> x=sympify('pow(PZ,2)') > >>>> x > > pow(PZ, 2) > >>>> Poly(x,Symbol('PZ')) > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > File "/data/ncsg3/pythonModules/lib/python2.5/site-packages/ > > sympy-0.6.4-py2.5.egg/sympy/polys/polynomial.py", line 402, in __new__ > > terms = Poly._decompose(poly, *symbols) > > File "/data/ncsg3/pythonModules/lib/python2.5/site-packages/ > > sympy-0.6.4-py2.5.egg/sympy/polys/polynomial.py", line 545, in > > _decompose > > raise PolynomialError("Can't decompose %s" % factor) > > sympy.polys.polynomial.PolynomialError: Can't decompose pow(PZ, 2) > > > Is this expected behaviour or should sympify convert pow(PZ,2) to > > PZ2? > > The sympify is indeed wrong. Could you debug what kind of "pow" it > generated? It's something different than if you type pow(PZ, 2) > yourself, as you can see here: > > In [1]: sympify("pow(PZ, 2)") > Out[1]: pow(PZ, 2) > > In [2]: var("PZ") > Out[2]: PZ > > In [3]: pow(PZ, 2) > Out[3]: > 2 > PZ > > Thanks, > Ondrej -- Dr Colin Gillespie http://www.mas.ncl.ac.uk/~ncsg3/ --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---