From ff4f5fcb20f3996a9ab5ceae30e934bf5c726929 Mon Sep 17 00:00:00 2001 From: "ondrej.certik" Date: Fri, 5 Oct 2007 14:28:01 +0000 Subject: [PATCH] fixed some more problem in powering integers --- sympy/core/numbers.py | 13 ++++++------- sympy/core/tests/test_arit.py | 8 ++++++-- sympy/polynomials/tests/test_polynomials.py | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/sympy/core/numbers.py b/sympy/core/numbers.py index a4719c1..617dbcb 100644 --- a/sympy/core/numbers.py +++ b/sympy/core/numbers.py @@ -682,13 +682,12 @@ class Integer(Rational): x, xexact = integer_nthroot(b.p, i) if xexact: return Integer(x)**(e * i) - else: - #TODO: check this, what is the else: doing here? - # Try to get some part of the base out, if exp > 1 - if e.p > e.q: - i = e.p / e.q - r = e.p % e.q - return b**i * b**Rational(r, e.q) + # Try to get some part of the base out, if exponent > 1 + if e.p > e.q: + i = e.p / e.q + r = e.p % e.q + return b**i * b**Rational(r, e.q) + else: return (-1)**e * (-b)**e diff --git a/sympy/core/tests/test_arit.py b/sympy/core/tests/test_arit.py index a889ffd..a115e8b 100644 --- a/sympy/core/tests/test_arit.py +++ b/sympy/core/tests/test_arit.py @@ -146,8 +146,8 @@ def testpow(): @XFAIL def test_pow2(): - # XXX These fail - the first three are maybe discutable, - # let's see SAGE and similar. The last one is a bug 417 + # XXX These fail - they are maybe discutable, + # let's see SAGE and similar. assert ((-x)**2)**Rational(1,3) == ((-x)**Rational(1,3))**2 assert (-x)**Rational(2,3) == x**Rational(2,3) assert (-x)**Rational(5,7) == -x**Rational(5,7) @@ -155,6 +155,10 @@ def test_pow2(): def test_pow_issue417(): assert 4**Rational(1, 4) == 2**Rational(1, 2) +def test_pow3(): + assert 2**(Rational(3)/2) == 2 * 2**Rational(1, 2) + assert 2**(Rational(3)/2) == sqrt(8) + def test_expand(): p = Rational(5) e = (a+b)*c diff --git a/sympy/polynomials/tests/test_polynomials.py b/sympy/polynomials/tests/test_polynomials.py index 0463635..4deecf1 100644 --- a/sympy/polynomials/tests/test_polynomials.py +++ b/sympy/polynomials/tests/test_polynomials.py @@ -5,6 +5,7 @@ import py from sympy import * from sympy.core.basic import S # Use Singleton comparisons. +Pi = pi ## sympy/modules/polynomials/base.py -- 2.11.4.GIT