No behaviour has changed, except for:

    - Real ** Even does not always get symplified by refine() to abs(Real) ** 
Even,
      only in the case of nested powers. This is now the same behaviour as 
Mathematica.

Relevant tests moved to queries/test/test_queries.py and 
refine/tests/test_refine.py
---
 sympy/core/add.py                                  |    7 --
 sympy/core/mul.py                                  |   28 +-----
 sympy/core/numbers.py                              |   23 ++---
 sympy/core/power.py                                |    9 --
 sympy/core/tests/test_arit.py                      |  110 --------------------
 sympy/core/tests/test_eval_power.py                |    8 --
 sympy/core/tests/test_numbers.py                   |    3 +-
 sympy/functions/elementary/exponential.py          |   19 ++--
 .../functions/elementary/tests/test_exponential.py |    5 -
 9 files changed, 18 insertions(+), 194 deletions(-)

diff --git a/sympy/core/add.py b/sympy/core/add.py
index 69ec473..917218a 100644
--- a/sympy/core/add.py
+++ b/sympy/core/add.py
@@ -234,13 +234,6 @@ def _eval_is_polynomial(self, syms):
     _eval_is_integer = lambda self: self._eval_template_is_attr('is_integer')
     _eval_is_comparable = lambda self: 
self._eval_template_is_attr('is_comparable')
 
-    def _eval_is_odd(self):
-        l = [f for f in self.args if not (f.is_even==True)]
-        if not l:
-            return False
-        if l[0].is_odd:
-            return Add(*l[1:]).is_even
-
     def _eval_is_irrational(self):
         for t in self.args:
             a = t.is_irrational
diff --git a/sympy/core/mul.py b/sympy/core/mul.py
index 6af50b3..27279e0 100644
--- a/sympy/core/mul.py
+++ b/sympy/core/mul.py
@@ -339,7 +339,7 @@ def _eval_power(b, e):
                 return coeff**e * Mul(*l)
 
         c,t = b.as_coeff_terms()
-        if e.is_even and c.is_Number and c < 0:
+        if e.is_Number and (e % 2 == 0) and c.is_Number and c < 0:
             return (-c * Mul(*t)) ** e
 
         #if e.atoms(Wild):
@@ -681,32 +681,6 @@ def _eval_is_negative(self):
         if c.is_nonnegative and r.is_nonnegative:
             return False
 
-    def _eval_is_odd(self):
-        is_integer = self.is_integer
-
-        if is_integer:
-            r = True
-            for t in self.args:
-                if t.is_even:
-                    return False
-                if t.is_odd is None:
-                    r = None
-            return r
-
-        # !integer -> !odd
-        elif is_integer == False:
-            return False
-
-
-    def _eval_is_even(self):
-        is_integer = self.is_integer
-
-        if is_integer:
-            return fuzzy_not(self._eval_is_odd())
-
-        elif is_integer == False:
-            return False
-
     def _eval_subs(self, old, new):
         if self == old:
             return new
diff --git a/sympy/core/numbers.py b/sympy/core/numbers.py
index 59e86e5..8940f57 100644
--- a/sympy/core/numbers.py
+++ b/sympy/core/numbers.py
@@ -606,11 +606,6 @@ def _eval_power(b, e):
                 else:
                     return (-1)**e * (-b)**e
 
-        c,t = b.as_coeff_terms()
-        if e.is_even and isinstance(c, Number) and c < 0:
-            return (-c * Mul(*t)) ** e
-
-        return
 
     def _as_mpf_val(self, prec):
         return mlib.from_rational(self.p, self.q, prec, rnd)
@@ -932,12 +927,6 @@ def _eval_power(base, exp):
             if base.p == -1: return S.NaN
             # cases 0, 1 are done in their respective classes
             return S.Infinity + S.ImaginaryUnit * S.Infinity
-        if not isinstance(exp, Number):
-            # simplify when exp is even
-            # (-2) ** k --> 2 ** k
-            c,t = base.as_coeff_terms()
-            if exp.is_even and isinstance(c, Number) and c < 0:
-                return (-c * Mul(*t)) ** exp
         if not isinstance(exp, Rational): return
         if exp is S.Half and base < 0:
             # we extract I for this special case since everyone is doing so
@@ -1090,18 +1079,20 @@ def __neg__():
         return S.One
 
     def _eval_power(b, e):
-        if e.is_odd: return S.NegativeOne
-        if e.is_even: return S.One
-        if isinstance(e, Number):
-            if isinstance(e, Real):
+        if e.is_Number:
+            if e.is_Real:
                 return Real(-1.0) ** e
+            if e.is_Integer:
+                if e % 2:
+                    return S.NegativeOne
+                else: return S.One
             if e is S.NaN:
                 return S.NaN
             if e is S.Infinity  or  e is S.NegativeInfinity:
                 return S.NaN
             if e is S.Half:
                 return S.ImaginaryUnit
-            if isinstance(e, Rational):
+            if e.is_Rational:
                 if e.q == 2:
                     return S.ImaginaryUnit ** Integer(e.p)
                 q = int(e)
diff --git a/sympy/core/power.py b/sympy/core/power.py
index 79e29f8..a485274 100644
--- a/sympy/core/power.py
+++ b/sympy/core/power.py
@@ -98,8 +98,6 @@ def _eval_power(self, other):
             return Pow(self.base, self.exp * other)
         if self.base.is_nonnegative and self.exp.is_real and other.is_real:
             return Pow(self.base, self.exp * other)
-        if self.exp.is_even and self.base.is_real:
-            return Pow(abs(self.base), self.exp * other)
         if self.exp.is_real and other.is_real and abs(self.exp) < S.One:
             return Pow(self.base, self.exp * other)
         return
@@ -111,13 +109,6 @@ def _eval_is_comparable(self):
         if c2 is None: return
         return c1 and c2
 
-    def _eval_is_even(self):
-        if self.exp.is_integer and self.exp.is_positive:
-            if self.base.is_even:
-                return True
-            if self.base.is_integer:
-                return False
-
     def _eval_is_positive(self):
         if self.base.is_positive:
             if self.exp.is_real:
diff --git a/sympy/core/tests/test_arit.py b/sympy/core/tests/test_arit.py
index 3a94bb3..9bd5ec1 100644
--- a/sympy/core/tests/test_arit.py
+++ b/sympy/core/tests/test_arit.py
@@ -138,14 +138,6 @@ def test_pow():
     assert (x**(y**(x+exp(x+y))+z)).expand(deep=False) == x**z*x**(y**(x + 
exp(x + y)))
     assert (x**(y**(x+exp(x+y))+z)).expand() == 
x**z*x**(y**x*y**(exp(x)*exp(y)))
 
-    n = Symbol('k', even=False)
-    k = Symbol('k', even=True)
-
-    assert (-1)**x == (-1)**x
-    assert (-1)**n == (-1)**n
-    assert (-2)**k == 2**k
-    assert (-1)**k == 1
-
 @XFAIL
 def test_pow2():
     # XXX These fail - they are maybe discutable,
@@ -308,77 +300,6 @@ def test_Add_Mul_is_bounded():
     assert (sin(x)-67).is_bounded == True
     assert (sin(x)+exp(x)).is_bounded == False
 
-def test_Mul_is_even_odd():
-    x = Symbol('x', integer=True)
-
-    k = Symbol('k', odd=True)
-    n = Symbol('n', odd=True)
-    m = Symbol('m', even=True)
-
-    assert (2*x).is_even == True
-    assert (2*x).is_odd == False
-
-    assert (3*x).is_even == None
-    assert (3*x).is_odd == None
-
-    assert (k/3).is_integer == False
-    assert (k/3).is_even    == False
-    assert (k/3).is_odd     == False
-
-    assert (2*n).is_even == True
-    assert (2*n).is_odd == False
-
-    assert (2*m).is_even == True
-    assert (2*m).is_odd == False
-
-    assert (-n).is_even == False
-    assert (-n).is_odd == True
-
-    assert (k*n).is_even == False
-    assert (k*n).is_odd == True
-
-    assert (k*m).is_even == True
-    assert (k*m).is_odd == False
-
-    assert (k*n*m).is_even == True
-    assert (k*n*m).is_odd == False
-
-    assert (k*m*x).is_even == True
-    assert (k*m*x).is_odd == False
-
-def test_Add_is_even_odd():
-    x = Symbol('x', integer=True)
-
-    k = Symbol('k', odd=True)
-    n = Symbol('n', even=True)
-
-    assert (2+k).is_even == False
-    assert (2+k).is_odd == True
-
-    assert (7-k).is_even == True
-    assert (7-k).is_odd == False
-
-    assert (11-n).is_even == False
-    assert (11-n).is_odd == True
-
-    assert (-8+n).is_even == True
-    assert (-8+n).is_odd == False
-
-    assert (n+k).is_even == False
-    assert (n+k).is_odd == True
-
-    assert (n-k).is_even == False
-    assert (n-k).is_odd == True
-
-    assert (n+2*k).is_even == True
-    assert (n+2*k).is_odd == False
-
-    assert (k+n+x).is_odd == None
-    assert (k+n-x).is_even == None
-
-    assert (2*k+n*x).is_odd == None
-    assert (2*k+n*x).is_even == None
-
 def test_Mul_is_negative_positive():
     x = Symbol('x', real=True)
     y = Symbol('y', real=False)
@@ -591,37 +512,6 @@ def test_Mul_is_nonpositive_nonnegative():
     assert (x*k).is_nonnegative == None
     assert (u*v*n*x*k).is_nonnegative == None
 
-def test_Add_is_even_odd():
-    x = Symbol('x', integer=True)
-
-    k = Symbol('k', odd=True)
-    n = Symbol('n', odd=True)
-    m = Symbol('m', even=True)
-
-    assert (k+7).is_even == True
-    assert (k+7).is_odd == False
-
-    assert (-k+7).is_even == True
-    assert (-k+7).is_odd == False
-
-    assert (k-12).is_even == False
-    assert (k-12).is_odd == True
-
-    assert (-k-12).is_even == False
-    assert (-k-12).is_odd == True
-
-    assert (k+n).is_even == True
-    assert (k+n).is_odd == False
-
-    assert (k+m).is_even == False
-    assert (k+m).is_odd == True
-
-    assert (k+n+m).is_even == True
-    assert (k+n+m).is_odd == False
-
-    assert (k+n+x+m).is_even == None
-    assert (k+n+x+m).is_odd == None
-
 def test_Add_is_negative_positive():
     x = Symbol('x', real=True)
 
diff --git a/sympy/core/tests/test_eval_power.py 
b/sympy/core/tests/test_eval_power.py
index 3f0ac6a..87d908f 100644
--- a/sympy/core/tests/test_eval_power.py
+++ b/sympy/core/tests/test_eval_power.py
@@ -38,12 +38,6 @@ def test_issue350():
     assert ((a**Rational(1,3))**Rational(2)) == a**Rational(2,3)
     assert ((a**Rational(3))**Rational(2,5)) == (a**Rational(3))**Rational(2,5)
 
-    a = Symbol('a', real=True)
-    b = Symbol('b', real=True)
-    assert (a**2)**b == abs(a)**(2*b)
-    assert sqrt(1/a) != 1/sqrt(a)
-    assert (a**3)**Rational(1,3) != a
-
     z = Symbol('z')
     k = Symbol('k',integer=True)
     m = Symbol('m',integer=True)
@@ -78,9 +72,7 @@ def test_issue1263():
 def test_issue1496():
     x = Symbol('x')
     y = Symbol('y')
-    n = Symbol('n', even=True)
     assert (3-y)**2 == (y-3)**2
-    assert (3-y)**n == (y-3)**n
     assert (-3+y-x)**2 == (3-y+x)**2
     assert (y-3)**3 == -(3-y)**3
 
diff --git a/sympy/core/tests/test_numbers.py b/sympy/core/tests/test_numbers.py
index 3e9cdfc..940886d 100644
--- a/sympy/core/tests/test_numbers.py
+++ b/sympy/core/tests/test_numbers.py
@@ -339,8 +339,7 @@ def test_issue324():
     assert sqrt(x-1) != I*(1-x)**Rational(1,2)
 
 def test_issue350():
-    x = Symbol("x", real=True)
-    assert sqrt(x**2) == abs(x)
+    x = Symbol("x")
     assert sqrt(x-1).subs(x,5) == 2
 
 
diff --git a/sympy/functions/elementary/exponential.py 
b/sympy/functions/elementary/exponential.py
index acb565d..24f1d49 100644
--- a/sympy/functions/elementary/exponential.py
+++ b/sympy/functions/elementary/exponential.py
@@ -45,16 +45,15 @@ def eval(cls, arg):
         elif arg.is_Mul:
             coeff = arg.as_coefficient(S.Pi*S.ImaginaryUnit)
 
-            if coeff is not None:
-                if (2*coeff).is_integer:
-                    if coeff.is_even:
-                        return S.One
-                    elif coeff.is_odd:
-                        return S.NegativeOne
-                    elif (coeff + S.Half).is_even:
-                        return -S.ImaginaryUnit
-                    elif (coeff + S.Half).is_odd:
-                        return S.ImaginaryUnit
+            if coeff and coeff.is_number:
+                if coeff % 2 == 0:
+                    return S.One
+                elif coeff % 2 == 1:
+                    return S.NegativeOne
+                elif (coeff + S.Half) % 2 == 0:
+                    return -S.ImaginaryUnit
+                elif (coeff + S.Half) % 2 == 1:
+                    return S.ImaginaryUnit
             I = S.ImaginaryUnit
             oo = S.Infinity
             a = Wild("a", exclude=[I, oo])
diff --git a/sympy/functions/elementary/tests/test_exponential.py 
b/sympy/functions/elementary/tests/test_exponential.py
index 37b9a54..5a331f7 100644
--- a/sympy/functions/elementary/tests/test_exponential.py
+++ b/sympy/functions/elementary/tests/test_exponential.py
@@ -21,11 +21,6 @@ def test_exp():
     assert exp(3*pi*I/2) == -I
     assert exp(2*pi*I) == 1
 
-    assert exp(pi*I*2*k) == 1
-    assert exp(pi*I*2*(k+Rational(1,2))) == -1
-    assert exp(pi*I*2*(k+Rational(1,4))) == I
-    assert exp(pi*I*2*(k+Rational(3,4))) == -I
-
     assert exp(log(x)) == x
     assert exp(2*log(x)) == x**2
     assert exp(pi*log(x)) == x**pi
-- 
1.6.4


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to