From aa4e9501237bbfac25a23da5059e3e496b337c79 Mon Sep 17 00:00:00 2001 From: Ondrej Certik Date: Fri, 15 Aug 2008 23:14:55 +0200 Subject: [PATCH] Make Pow able not to sympify. Signed-off-by: Ondrej Certik --- sympy_py.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sympy_py.py b/sympy_py.py index 2d00aa1..c923389 100644 --- a/sympy_py.py +++ b/sympy_py.py @@ -412,11 +412,12 @@ class Mul(Basic): class Pow(Basic): - def __new__(cls, args, canonicalize=True): + def __new__(cls, args, canonicalize=True, do_sympify=True): if canonicalize == False: obj = Basic.__new__(cls, POW, args) return obj - args = [sympify(x) for x in args] + if do_sympify: + args = [sympify(x) for x in args] return Pow.canonicalize(args) @classmethod @@ -465,7 +466,11 @@ class Pow(Basic): t = [Integer(coeff)] for x, p in zip(base.args, powers): if p != 0: - t.append(Pow((x, p))) + if p == 1: + tt = x + else: + tt = Pow((x, Integer(p)), do_sympify=False) + t.append(tt) assert len(t) != 0 if len(t) == 1: t = t[0] -- 2.11.4.GIT