Repository: sympy/sympy

Issue:
bad ceiling(sqrt(big integer))
```python
import sympy
ll = 1206577996382235787095214 # lower limit for x**2
x = sympy.ceiling(sympy.sqrt(ll))
assert (x-1)**2 < ll and x**2 >= ll
```

fails in a python3 notebook on jupyter.org.

Discussion:
smichr: > precision limit

When I run your loops (after defining copysign) I find that the first failure occurs for taking the sqrt of a negative number. Although ceiling of an imaginary number works, comparison of that imaginary result via relational will not work:

```
>>> x=-1020
>>> x,rf,rc=(x, floor(sqrt(x)), ceiling(sqrt(x)))
>>> assert (rf == rc) == ((rf**2) == x)
>>> assert (rc-1)**2 < x and rc**2 >= x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy\core\relational.py", line 202, in __nonzero__
    raise TypeError("cannot determine truth value of Relational")
TypeError: cannot determine truth value of Relational
>>> (rc-1)**2 < x
(-1 + 32*I)**2 < -1020
>>> expand(_)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy\core\function.py", line 2018, in expand
    return sympify(e).expand(deep=deep, modulus=modulus, **hints)
  File "sympy\core\cache.py", line 95, in wrapper
    retval = func(*args, **kwargs)
  File "sympy\core\expr.py", line 2942, in expand
    expr, hit = Expr._expand_hint(expr, hint, deep=deep, **hints)
  File "sympy\core\expr.py", line 2880, in _expand_hint
    expr = expr.func(*sargs)
  File "sympy\core\relational.py", line 407, in __new__
    r = cls._eval_relation(lhs, rhs)
  File "sympy\core\relational.py", line 742, in _eval_relation
    return _sympify(lhs.__lt__(rhs))
  File "sympy\core\expr.py", line 299, in __lt__
    raise TypeError("Invalid comparison of complex %s" % me)
TypeError: Invalid comparison of complex -1023 - 64*I
```

smichr: Regarding the apparent failure for `ceiling(sqrt(2**3000 + 1)) == 2**1500 + 1`:

```python
>>> type(ceiling(sqrt(2**3000 + 1)))
ceiling
>>> ceiling(sqrt(2**3000 + 1)) - (2**1500+1)
Traceback (most recent call last):
...
sympy.core.evalf.PrecisionExhausted
```

The value remains unevaluated so that's why the equality fails.  And if you try to calculate the difference between the two, you get an error because the allowed precision was exhausted in trying to find the difference.

Patch:
diff --git a/.mailmap b/.mailmap
index 7f8494ae58..97e8aa9f66 100644
--- a/.mailmap
+++ b/.mailmap
@@ -221,9 +221,3 @@ Sampad Kumar Saha <sampadsaha5@gmail.com> sampadsaha5 <sampadsaha5@gmail.com>
 Jiaxing Liang <liangjiaxing57@gmail.com> unknown <jiaxingl@CS-DEAL-03.cs.sfu.ca>
 Jiaxing Liang <liangjiaxing57@gmail.com> liangjiaxing <liangjiaxing57@gmail.com>
 Jens Jørgen Mortensen <jj@smoerhul.dk> jjmortensen <jj@smoerhul.dk>
-Björn Dahlgren <bjodah@gmail.com> Björn Dahlhren <bjodah@gmail.com>
-Shekhar Prasad Rajak <shekharrajak@live.com> Shekhar Prasad Rajak <shekharstudy@ymail.com>
-Arafat Dad Khan <arafat.da.khan@gmail.com> Arafat <arafat.da.khan@gmail.com>
-Aqnouch Mohammed <aqnouch.mohammed@gmail.com> AQNOUCH Mohammed <aqnouch.mohammed@gmail.com>
-Meghana Madhyastha <meghana.madhyastha@gmail.com> Meghana <meghana.madhyastha@gmail.com>
-Tanu Hari Dixit <tokencolour@gmail.com> tokencolour <tokencolour@gmail.com>
diff --git a/AUTHORS b/AUTHORS
index 13adde6e78..d9f1362c5b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -458,9 +458,3 @@ Jens Jørgen Mortensen <jj@smoerhul.dk>
 Sampad Kumar Saha <sampadsaha5@gmail.com>
 Eva Charlotte Mayer <eva-charlotte.mayer@posteo.de>
 Laura Domine <temigo@gmx.com>
-Justin Blythe <jblythe29@gmail.com>
-Meghana Madhyastha <meghana.madhyastha@gmail.com>
-Tanu Hari Dixit <tokencolour@gmail.com>
-Shekhar Prasad Rajak <shekharrajak@live.com>
-Aqnouch Mohammed <aqnouch.mohammed@gmail.com>
-Arafat Dad Khan <arafat.da.khan@gmail.com>
diff --git a/LICENSE b/LICENSE
index df5f217d42..01be471668 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2006-2016 SymPy Development Team
+Copyright (c) 2006-2015 SymPy Development Team
 
 All rights reserved.
 
diff --git a/doc/src/aboutus.rst b/doc/src/aboutus.rst
index 972c7d42b3..281892d5fc 100644
--- a/doc/src/aboutus.rst
+++ b/doc/src/aboutus.rst
@@ -431,7 +431,6 @@ want to be mentioned here, so see our repository history for a full list).
 #. Matthew Davis: Fixed documentation typos
 #. Jack Kemp: Fix incorrect assignment of free variables in linsolve
 #. Kshitij Saraogi: Parenthesized printing of Intersections
-#. Arafat Dad Khan: improve detection of polygon/ellipse intersection
 
 Up-to-date list in the order of the first contribution is given in the `AUTHORS
 <https://github.com/sympy/sympy/blob/master/AUTHORS>`_ file.
diff --git a/sympy/assumptions/satask.py b/sympy/assumptions/satask.py
index 114e98bfa4..64f0136ca5 100644
--- a/sympy/assumptions/satask.py
+++ b/sympy/assumptions/satask.py
@@ -36,8 +36,7 @@ def satask(proposition, assumptions=True, context=global_assumptions,
 
 
 def get_relevant_facts(proposition, assumptions=(True,),
-    context=global_assumptions, use_known_facts=True, exprs=None,
-    relevant_facts=None):
+    context=global_assumptions, use_known_facts=True, exprs=None, relevant_facts=None):
 
     newexprs = set()
     if not exprs:
@@ -76,10 +75,8 @@ def get_all_relevant_facts(proposition, assumptions=True,
     relevant_facts = set()
     exprs = None
     while exprs != set():
-        (relevant_facts, exprs) = get_relevant_facts(proposition,
-                And.make_args(assumptions), context,
-                use_known_facts=use_known_facts, exprs=exprs,
-                relevant_facts=relevant_facts)
+        (relevant_facts, exprs) = get_relevant_facts(proposition, And.make_args(assumptions),
+                context, use_known_facts=use_known_facts, exprs=exprs, relevant_facts=relevant_facts)
         i += 1
         if i >= iterations:
             return And(*relevant_facts)
diff --git a/sympy/core/evalf.py b/sympy/core/evalf.py
index 2fc8d987b1..c568ae1277 100644
--- a/sympy/core/evalf.py
+++ b/sympy/core/evalf.py
@@ -291,7 +291,7 @@ def get_integer_part(expr, no, options, return_ints=False):
 
     Note: this function either gives the exact result or signals failure.
     """
-    import sympy
+    from sympy.functions.elementary.complexes import re, im
     # The expression is likely less than 2^30 or so
     assumed_size = 30
     ire, iim, ire_acc, iim_acc = evalf(expr, assumed_size, options)
@@ -318,10 +318,31 @@ def get_integer_part(expr, no, options, return_ints=False):
     # must also calculate whether the difference to the nearest integer is
     # positive or negative (which may fail if very close).
     def calc_part(expr, nexpr):
-        from sympy import Add
+        from sympy.core.add import Add
         nint = int(to_int(nexpr, rnd))
         n, c, p, b = nexpr
-        if (c != 1 and p != 0) or p < 0:
+        is_int = (p == 0)
+        if not is_int:
+            # if there are subs and they all contain integer re/im parts
+            # then we can (hopefully) safely substitute them into the
+            # expression
+            s = options.get('subs', False)
+            if s:
+                doit = True
+                from sympy.core.compatibility import as_int
+                for v in s.values():
+                    try:
+                        as_int(v)
+                    except ValueError:
+                        try:
+                            [as_int(i) for i in v.as_real_imag()]
+                            continue
+                        except (ValueError, AttributeError):
+                            doit = False
+                            break
+                if doit:
+                    expr = expr.subs(s)
+
             expr = Add(expr, -nint, evaluate=False)
             x, _, x_acc, _ = evalf(expr, 10, options)
             try:
@@ -334,16 +355,16 @@ def calc_part(expr, nexpr):
         nint = from_int(nint)
         return nint, fastlog(nint) + 10
 
-    re, im, re_acc, im_acc = None, None, None, None
+    re_, im_, re_acc, im_acc = None, None, None, None
 
     if ire:
-        re, re_acc = calc_part(sympy.re(expr, evaluate=False), ire)
+        re_, re_acc = calc_part(re(expr, evaluate=False), ire)
     if iim:
-        im, im_acc = calc_part(sympy.im(expr, evaluate=False), iim)
+        im_, im_acc = calc_part(im(expr, evaluate=False), iim)
 
     if return_ints:
-        return int(to_int(re or fzero)), int(to_int(im or fzero))
-    return re, im, re_acc, im_acc
+        return int(to_int(re_ or fzero)), int(to_int(im_ or fzero))
+    return re_, im_, re_acc, im_acc
 
 
 def evalf_ceiling(expr, prec, options):
diff --git a/sympy/crypto/crypto.py b/sympy/crypto/crypto.py
index ee55da732e..41dbdbbb98 100644
--- a/sympy/crypto/crypto.py
+++ b/sympy/crypto/crypto.py
@@ -1557,7 +1557,7 @@ def encipher_elgamal(m, puk):
 
     """
     if m > puk[0]:
-        raise ValueError('Message {} should be less than prime {}'.format(m, puk[0]))
+        ValueError('Message {} should be less than prime {}'.format(m, puk[0]))
     r = randrange(2, puk[0])
     return pow(puk[1], r, puk[0]), m * pow(puk[2], r, puk[0]) % puk[0]
 
@@ -1708,6 +1708,6 @@ def dh_shared_key(puk, b):
     """
     p, _, x = puk
     if 1 >= b or b >= p:
-        raise ValueError('Value of b should be greater 1 and less than prime {}'\
+        ValueError('Value of b should be greater 1 and less than prime {}'\
                 .format(p))
     return pow(x, b, p)
diff --git a/sympy/geometry/entity.py b/sympy/geometry/entity.py
index 5f9d07ea95..af3ed9fad8 100644
--- a/sympy/geometry/entity.py
+++ b/sympy/geometry/entity.py
@@ -258,7 +258,7 @@ def encloses(self, o):
         elif isinstance(o, Ray) or isinstance(o, Line):
             return False
         elif isinstance(o, Ellipse):
-            return self.encloses_point(o.center) and not self.intersection(o) and self.encloses_point(Point(o.center.x+o.hradius,o.center.y))
+            return self.encloses_point(o.center) and not self.intersection(o)
         elif isinstance(o, Polygon):
             if isinstance(o, RegularPolygon):
                 if not self.encloses_point(o.center):
diff --git a/sympy/integrals/risch.py b/sympy/integrals/risch.py
index ed75b61794..9b8fea56e4 100644
--- a/sympy/integrals/risch.py
+++ b/sympy/integrals/risch.py
@@ -25,7 +25,7 @@
 """
 from __future__ import print_function, division
 
-from sympy import real_roots, default_sort_key
+from sympy import real_roots
 from sympy.abc import z
 from sympy.core.function import Lambda
 from sympy.core.numbers import ilcm, oo
@@ -160,7 +160,7 @@ class DifferentialExtension(object):
     # to have a safeguard when debugging.
     __slots__ = ('f', 'x', 'T', 'D', 'fa', 'fd', 'Tfuncs', 'backsubs', 'E_K',
         'E_args', 'L_K', 'L_args', 'cases', 'case', 't', 'd', 'newf', 'level',
-        'ts',)
+        'ts')
 
     def __init__(self, f=None, x=None, handle_first='log', dummy=True, extension=None, rewrite_complex=False):
         """
@@ -247,6 +247,7 @@ def update(seq, atoms, func):
         symlogs = set()
 
         while True:
+            restart = False
             if self.newf.is_rational_function(*self.T):
                 break
 
@@ -326,12 +327,6 @@ def update(seq, atoms, func):
                         # ANSWER: Yes, otherwise we can't integrate x**x (or
                         # rather prove that it has no elementary integral)
                         # without first manually rewriting it as exp(x*log(x))
-                        self.newf = self.newf.xreplace({old: new})
-                        self.backsubs += [(new, old)]
-                        log_new_extension = self._log_part([log(i.base)],
-                            dummy=dummy)
-                        exps = update(exps, self.newf.atoms(exp), lambda i:
-                            i.exp.is_rational_function(*self.T) and i.exp.has(*self.T))
                         continue
                     ans, u, const = A
                     newterm = exp(i.exp*(log(const) + u))
@@ -382,7 +377,7 @@ def update(seq, atoms, func):
                 self.backsubs.append((new, i))
 
             # remove any duplicates
-            logs = sorted(set(logs), key=default_sort_key)
+            logs = list(set(logs))
 
             if handle_first == 'exp' or not log_new_extension:
                 exp_new_extension = self._exp_part(exps, dummy=dummy)
@@ -745,7 +740,7 @@ def as_poly_1t(p, t, z):
     Examples
     ========
 
-    >>> from sympy import random_poly
+    >>> from sympy import Symbol, random_poly
     >>> from sympy.integrals.risch import as_poly_1t
     >>> from sympy.abc import x, z
 
@@ -1652,11 +1647,11 @@ def risch_integrate(f, x, extension=None, handle_first='log',
     >>> pprint(risch_integrate(x*x**x*log(x) + x**x + x*x**x, x))
        x
     x*x
-    >>> pprint(risch_integrate(x**x, x))
+    >>> pprint(risch_integrate(x**x*log(x), x))
       /
      |
      |  x
-     | x  dx
+     | x *log(x) dx
      |
     /
 
diff --git a/sympy/physics/vector/frame.py b/sympy/physics/vector/frame.py
index 6d6d1b2c55..5f693bc166 100644
--- a/sympy/physics/vector/frame.py
+++ b/sympy/physics/vector/frame.py
@@ -1,5 +1,5 @@
 from sympy import (diff, trigsimp, expand, sin, cos, solve, Symbol, sympify,
-                   eye, symbols, Dummy, ImmutableMatrix as Matrix)
+                   eye, ImmutableMatrix as Matrix)
 from sympy.core.compatibility import string_types, u, range
 from sympy.physics.vector.vector import Vector, _check_vector
 
@@ -586,7 +586,7 @@ def _rot(axis, angle):
                 from sympy.polys.polyerrors import CoercionFailed
                 from sympy.physics.vector.functions import kinematic_equations
                 q1, q2, q3 = amounts
-                u1, u2, u3 = symbols('u1, u2, u3', cls=Dummy)
+                u1, u2, u3 = dynamicsymbols('u1, u2, u3')
                 templist = kinematic_equations([u1, u2, u3], [q1, q2, q3],
                                                rot_type, rot_order)
                 templist = [expand(i) for i in templist]
diff --git a/sympy/sets/sets.py b/sympy/sets/sets.py
index d57020821e..ac7a486dba 100644
--- a/sympy/sets/sets.py
+++ b/sympy/sets/sets.py
@@ -206,7 +206,7 @@ def _complement(self, other):
             return Union(o - self for o in other.args)
 
         elif isinstance(other, Complement):
-            return Complement(other.args[0], Union(other.args[1], self), evaluate=False)
+            return Complement(other.args[0], Union(other.args[1], self))
 
         elif isinstance(other, EmptySet):
             return S.EmptySet
@@ -964,10 +964,9 @@ def _boundary(self):
         return FiniteSet(self.start, self.end)
 
     def _contains(self, other):
-        if other.is_real is False or other is S.NegativeInfinity or other is S.Infinity:
+        if other.is_real is False:
             return false
 
-
         if self.start is S.NegativeInfinity and self.end is S.Infinity:
             if not other.is_real is None:
                 return other.is_real
diff --git a/sympy/solvers/inequalities.py b/sympy/solvers/inequalities.py
index c73052a1a7..6baa44e38c 100644
--- a/sympy/solvers/inequalities.py
+++ b/sympy/solvers/inequalities.py
@@ -215,7 +215,7 @@ def reduce_rational_inequalities(exprs, gen, relational=True):
     """
     exact = True
     eqs = []
-    solution = S.Reals if exprs else S.EmptySet
+    solution = S.EmptySet
     for _exprs in exprs:
         _eqs = []
 
@@ -251,15 +251,13 @@ def reduce_rational_inequalities(exprs, gen, relational=True):
             if not (domain.is_ZZ or domain.is_QQ):
                 expr = numer/denom
                 expr = Relational(expr, 0, rel)
-                solution &= solve_univariate_inequality(expr, gen, relational=False)
+                solution = Union(solution, solve_univariate_inequality(expr, gen, relational=False))
             else:
                 _eqs.append(((numer, denom), rel))
 
-        if _eqs:
-            eqs.append(_eqs)
+        eqs.append(_eqs)
 
-    if eqs:
-        solution &= solve_rational_inequalities(eqs)
+    solution = Union(solution, solve_rational_inequalities(eqs))
 
     if not exact:
         solution = solution.evalf()
diff --git a/sympy/tensor/array/ndim_array.py b/sympy/tensor/array/ndim_array.py
index 5846504a34..3700f076c7 100644
--- a/sympy/tensor/array/ndim_array.py
+++ b/sympy/tensor/array/ndim_array.py
@@ -112,10 +112,6 @@ def _handle_ndarray_creation_inputs(cls, iterable=None, shape=None, **kwargs):
         if shape is None and iterable is None:
             shape = ()
             iterable = ()
-        # Construction from another `NDimArray`:
-        elif shape is None and isinstance(iterable, NDimArray):
-            shape = iterable.shape
-            iterable = list(iterable)
         # Construct N-dim array from an iterable (numpy arrays included):
         elif shape is None and isinstance(iterable, collections.Iterable):
             iterable, shape = cls._scan_iterable_shape(iterable)
@@ -190,37 +186,6 @@ def rank(self):
         """
         return self._rank
 
-    def diff(self, *args):
-        """
-        Calculate the derivative of each element in the array.
-
-        Examples
-        ========
-
-        >>> from sympy.tensor.array import ImmutableDenseNDimArray
-        >>> from sympy.abc import x, y
-        >>> M = ImmutableDenseNDimArray([[x, y], [1, x*y]])
-        >>> M.diff(x)
-        [[1, 0], [0, y]]
-
-        """
-        return type(self)(map(lambda x: x.diff(*args), self), self.shape)
-
-    def applyfunc(self, f):
-        """Apply a function to each element of the N-dim array.
-
-        Examples
-        ========
-
-        >>> from sympy.tensor.array import ImmutableDenseNDimArray
-        >>> m = ImmutableDenseNDimArray([i*2+j for i in range(2) for j in range(2)], (2, 2))
-        >>> m
-        [[0, 1], [2, 3]]
-        >>> m.applyfunc(lambda i: 2*i)
-        [[0, 2], [4, 6]]
-        """
-        return type(self)(map(f, self), self.shape)
-
     def __str__(self):
         """Returns string, allows to use standard functions print() and str().
 
diff --git a/sympy/tensor/array/sparse_ndim_array.py b/sympy/tensor/array/sparse_ndim_array.py
index 66979cf01e..e1bb779dc3 100644
--- a/sympy/tensor/array/sparse_ndim_array.py
+++ b/sympy/tensor/array/sparse_ndim_array.py
@@ -1,8 +1,6 @@
 from __future__ import print_function, division
 import functools
 
-import itertools
-
 from sympy.core.sympify import _sympify
 
 from sympy import S, Dict, flatten, SparseMatrix, Basic, Tuple
@@ -36,30 +34,12 @@ def __getitem__(self, index):
         2
 
         """
-        # `index` is a tuple with one or more slices:
-        if isinstance(index, tuple) and any([isinstance(i, slice) for i in index]):
-
-            def slice_expand(s, dim):
-                if not isinstance(s, slice):
-                        return (s,)
-                start, stop, step = s.indices(dim)
-                return [start + i*step for i in range((stop-start)//step)]
-
-            sl_factors = [slice_expand(i, dim) for (i, dim) in zip(index, self.shape)]
-            eindices = itertools.product(*sl_factors)
-            array = [self._sparse_array.get(self._parse_index(i), S.Zero) for i in eindices]
-            nshape = [len(el) for i, el in enumerate(sl_factors) if isinstance(index[i], slice)]
-            return type(self)(array, nshape)
+        index = self._parse_index(index)
+
+        if index in self._sparse_array:
+            return self._sparse_array[index]
         else:
-            # `index` is a single slice:
-            if isinstance(index, slice):
-                start, stop, step = index.indices(self._loop_size)
-                retvec = [self._sparse_array.get(ind, S.Zero) for ind in range(start, stop, step)]
-                return retvec
-            # `index` is a number or a tuple without any slice:
-            else:
-                index = self._parse_index(index)
-                return self._sparse_array.get(index, S.Zero)
+            return S.Zero
 
     @classmethod
     def zeros(cls, *shape):


Test patch:
diff --git a/sympy/core/tests/test_evalf.py b/sympy/core/tests/test_evalf.py
index adf7ec2fa4..dbee33fe96 100644
--- a/sympy/core/tests/test_evalf.py
+++ b/sympy/core/tests/test_evalf.py
@@ -243,6 +243,9 @@ def test_evalf_integer_parts():
     assert ceiling(x).evalf(subs={x: 3}) == 3
     assert ceiling(x).evalf(subs={x: 3*I}) == 3*I
     assert ceiling(x).evalf(subs={x: 2 + 3*I}) == 2 + 3*I
+    assert ceiling(x).evalf(subs={x: 3.}) == 3
+    assert ceiling(x).evalf(subs={x: 3.*I}) == 3*I
+    assert ceiling(x).evalf(subs={x: 2. + 3*I}) == 2 + 3*I
 
 
 def test_evalf_trig_zero_detection():
@@ -473,3 +476,7 @@ def test_issue_9326():
     d2 = Dummy('d')
     e = d1 + d2
     assert e.evalf(subs = {d1: 1, d2: 2}) == 3
+
+
+def test_issue_10323():
+    assert ceiling(sqrt(2**30 + 1)) == 2**15 + 1
diff --git a/sympy/crypto/tests/test_crypto.py b/sympy/crypto/tests/test_crypto.py
index e6af68682f..688ccc09fe 100644
--- a/sympy/crypto/tests/test_crypto.py
+++ b/sympy/crypto/tests/test_crypto.py
@@ -255,7 +255,6 @@ def test_elgamal():
     ek = elgamal_public_key(dk)
     m = 12345
     assert m == decipher_elgamal(encipher_elgamal(m, ek), dk)
-    raises(ValueError, lambda: encipher_elgamal(2000, (1031, 14, 212)))
 
 def test_dh_private_key():
     p, g, _ = dh_private_key(digit = 100)
@@ -276,4 +275,3 @@ def test_dh_shared_key():
     b = randrange(2, p)
     sk = dh_shared_key((p, _, ga), b)
     assert sk == pow(ga, b, p)
-    raises(ValueError, lambda: dh_shared_key((1031, 14, 565), 2000))
diff --git a/sympy/geometry/tests/test_polygon.py b/sympy/geometry/tests/test_polygon.py
index cef5a5cf05..37604e5392 100644
--- a/sympy/geometry/tests/test_polygon.py
+++ b/sympy/geometry/tests/test_polygon.py
@@ -3,7 +3,7 @@
 
 from sympy import Abs, Rational, Float, S, Symbol, cos, pi, sqrt, oo
 from sympy.functions.elementary.trigonometric import tan
-from sympy.geometry import (Circle, Ellipse, GeometryError, Point, Polygon, Ray, RegularPolygon, Segment, Triangle, are_similar,
+from sympy.geometry import (Circle, GeometryError, Point, Polygon, Ray, RegularPolygon, Segment, Triangle, are_similar,
                             convex_hull, intersection, Line)
 from sympy.utilities.pytest import raises
 from sympy.utilities.randtest import verify_numerically
@@ -78,8 +78,6 @@ def test_polygon():
     assert p5.encloses_point(Point(1, 3))
     assert p5.encloses_point(Point(0, 0)) is False
     assert p5.encloses_point(Point(4, 0)) is False
-    assert p1.encloses(Circle(Point(2.5,2.5),5)) is False
-    assert p1.encloses(Ellipse(Point(2.5,2),5,6)) is False
     p5.plot_interval('x') == [x, 0, 1]
     assert p5.distance(
         Polygon(Point(10, 10), Point(14, 14), Point(10, 14))) == 6 * sqrt(2)
diff --git a/sympy/integrals/tests/test_risch.py b/sympy/integrals/tests/test_risch.py
index a0ad2fe2ae..3258230ec1 100644
--- a/sympy/integrals/tests/test_risch.py
+++ b/sympy/integrals/tests/test_risch.py
@@ -461,11 +461,9 @@ def test_DifferentialExtension_log():
 
 
 def test_DifferentialExtension_symlog():
-    # See comment on test_risch_integrate below
     assert DifferentialExtension(log(x**x), x, dummy=False)._important_attrs == \
-        (Poly(t0*x, t1), Poly(1, t1), [Poly(1, x), Poly(1/x, t0), Poly((t0 +
-            1)*t1, t1)], [x, t0, t1], [Lambda(i, log(i)), Lambda(i, exp(i*t0))],
-            [(exp(x*log(x)), x**x)], [2], [t0*x], [1], [x])
+        (Poly(x*t0, t0), Poly(1, t0), [Poly(1, x), Poly(1/x, t0)], [x, t0],
+        [Lambda(i, log(i))], [(x*log(x), log(x**x))], [], [], [1], [x])
     assert DifferentialExtension(log(x**y), x, dummy=False)._important_attrs == \
         (Poly(y*t0, t0), Poly(1, t0), [Poly(1, x), Poly(1/x, t0)], [x, t0],
         [Lambda(i, log(i))], [(y*log(x), log(x**y))], [], [], [1], [x])
@@ -646,14 +644,7 @@ def test_risch_integrate():
     # These are tested here in addition to in test_DifferentialExtension above
     # (symlogs) to test that backsubs works correctly.  The integrals should be
     # written in terms of the original logarithms in the integrands.
-
-    # XXX: Unfortunately, making backsubs work on this one is a little
-    # trickier, because x**x is converted to exp(x*log(x)), and so log(x**x)
-    # is converted to x*log(x). (x**2*log(x)).subs(x*log(x), log(x**x)) is
-    # smart enough, the issue is that these splits happen at different places
-    # in the algorithm.  Maybe a heuristic is in order
-    assert risch_integrate(log(x**x), x) == x**2*log(x)/2 - x**2/4
-
+    assert risch_integrate(log(x**x), x) == x*log(x**x)/2 - x**2/4
     assert risch_integrate(log(x**y), x) == x*log(x**y) - x*y
     assert risch_integrate(log(sqrt(x)), x) == x*log(sqrt(x)) - x/2
 
@@ -667,8 +658,3 @@ def test_NonElementaryIntegral():
     assert isinstance(risch_integrate(x**x*log(x), x), NonElementaryIntegral)
     # Make sure methods of Integral still give back a NonElementaryIntegral
     assert isinstance(NonElementaryIntegral(x**x*t0, x).subs(t0, log(x)), NonElementaryIntegral)
-
-def test_xtothex():
-    a = risch_integrate(x**x, x)
-    assert a == NonElementaryIntegral(x**x, x)
-    assert isinstance(a, NonElementaryIntegral)
diff --git a/sympy/interactive/tests/test_ipythonprinting.py b/sympy/interactive/tests/test_ipythonprinting.py
index 211e6cd417..9cb6e1f9db 100644
--- a/sympy/interactive/tests/test_ipythonprinting.py
+++ b/sympy/interactive/tests/test_ipythonprinting.py
@@ -64,8 +64,7 @@ def test_print_builtin_option():
     else:
         text = app.user_ns['a'][0]['text/plain']
         raises(KeyError, lambda: app.user_ns['a'][0]['text/latex'])
-    # Note : Unicode of Python2 is equivalent to str in Python3. In Python 3 we have one
-    # text type: str which holds Unicode data and two byte types bytes and bytearray.
+    # Note : In Python 3 the text is unicode, but in 2 it is a string.
     # XXX: How can we make this ignore the terminal width? This test fails if
     # the terminal is too narrow.
     assert text in ("{pi: 3.14, n_i: 3}",
@@ -101,8 +100,7 @@ def test_print_builtin_option():
     else:
         text = app.user_ns['a'][0]['text/plain']
         raises(KeyError, lambda: app.user_ns['a'][0]['text/latex'])
-    # Note : Unicode of Python2 is equivalent to str in Python3. In Python 3 we have one
-    # text type: str which holds Unicode data and two byte types bytes and bytearray.
+    # Note : In Python 3 the text is unicode, but in 2 it is a string.
     # Python 3.3.3 + IPython 0.13.2 gives: '{n_i: 3, pi: 3.14}'
     # Python 3.3.3 + IPython 1.1.0 gives: '{n_i: 3, pi: 3.14}'
     # Python 2.7.5 + IPython 1.1.0 gives: '{pi: 3.14, n_i: 3}'
diff --git a/sympy/physics/vector/tests/test_frame.py b/sympy/physics/vector/tests/test_frame.py
index 153f477fed..f66a953d6d 100644
--- a/sympy/physics/vector/tests/test_frame.py
+++ b/sympy/physics/vector/tests/test_frame.py
@@ -164,9 +164,3 @@ class MyReferenceFrame(ReferenceFrame):
     B = MyReferenceFrame('B')
     C = B.orientnew('C', 'Axis', [0, B.x])
     assert isinstance(C, MyReferenceFrame)
-
-
-def test_issue_10348():
-    u = dynamicsymbols('u:3')
-    I = ReferenceFrame('I')
-    A = I.orientnew('A', 'space', u, 'XYZ')
diff --git a/sympy/sets/tests/test_contains.py b/sympy/sets/tests/test_contains.py
index ab1c06c26c..c48e04f052 100644
--- a/sympy/sets/tests/test_contains.py
+++ b/sympy/sets/tests/test_contains.py
@@ -1,4 +1,4 @@
-from sympy import Symbol, Contains, S, Interval, FiniteSet, oo
+from sympy import Symbol, Contains, S, Interval, FiniteSet
 
 
 def test_contains_basic():
@@ -15,8 +15,3 @@ def test_issue_6194():
     assert Contains(x, FiniteSet(0)) != S.false
     assert Contains(x, Interval(1, 1)) != S.false
     assert Contains(x, S.Integers) != S.false
-
-
-def test_issue_10326():
-    assert Contains(oo, Interval(-oo, oo)) == False
-    assert Contains(-oo, Interval(-oo, oo)) == False
diff --git a/sympy/sets/tests/test_sets.py b/sympy/sets/tests/test_sets.py
index ec7538cdd0..1afe34c7bb 100644
--- a/sympy/sets/tests/test_sets.py
+++ b/sympy/sets/tests/test_sets.py
@@ -161,6 +161,7 @@ def test_Complement():
     assert S.Reals - Union(S.Naturals, FiniteSet(pi)) == \
             Intersection(S.Reals - S.Naturals, S.Reals - FiniteSet(pi))
 
+
 def test_complement():
     assert Interval(0, 1).complement(S.Reals) == \
         Union(Interval(-oo, 0, True, True), Interval(1, oo, True, True))
@@ -940,11 +941,3 @@ def test_issue_10113():
 def test_issue_10248():
     assert list(Intersection(S.Reals, FiniteSet(x))) == [
         And(x < oo, x > -oo)]
-
-
-def test_issue_9447():
-    a = Interval(0, 1) + Interval(2, 3)
-    assert Complement(S.UniversalSet, a) == Complement(
-            S.UniversalSet, Union(Interval(0, 1), Interval(2, 3)), evaluate=False)
-    assert Complement(S.Naturals, a) == Complement(
-            S.Naturals, Union(Interval(0, 1), Interval(2, 3)), evaluate=False)
diff --git a/sympy/solvers/tests/test_inequalities.py b/sympy/solvers/tests/test_inequalities.py
index 5ab366e2cd..ef606209a4 100644
--- a/sympy/solvers/tests/test_inequalities.py
+++ b/sympy/solvers/tests/test_inequalities.py
@@ -168,10 +168,6 @@ def test_reduce_rational_inequalities_real_relational():
         relational=False) == \
         Union(Interval.Lopen(-oo, -2), Interval.Lopen(0, 4))
 
-    # issue sympy/sympy#10237
-    assert reduce_rational_inequalities(
-        [[x < oo, x >= 0, -oo < x]], x, relational=False) == Interval(0, oo)
-
 
 def test_reduce_abs_inequalities():
     e = abs(x - 5) < 3
diff --git a/sympy/tensor/array/tests/test_immutable_ndim_array.py b/sympy/tensor/array/tests/test_immutable_ndim_array.py
index cda2e13afb..8bfbdf3984 100644
--- a/sympy/tensor/array/tests/test_immutable_ndim_array.py
+++ b/sympy/tensor/array/tests/test_immutable_ndim_array.py
@@ -257,31 +257,3 @@ def test_slices():
     assert md[0, 1:2, :].tomatrix() == Matrix([[14, 15, 16, 17]])
     assert md[0, 1:3, :].tomatrix() == Matrix([[14, 15, 16, 17], [18, 19, 20, 21]])
     assert md[:, :, :] == md
-
-    sd = ImmutableSparseNDimArray(range(10, 34), (2, 3, 4))
-    assert sd == ImmutableSparseNDimArray(md)
-
-    assert sd[:] == md._array
-    assert sd[:] == list(sd)
-    assert sd[:, :, 0].tomatrix() == Matrix([[10, 14, 18], [22, 26, 30]])
-    assert sd[0, 1:2, :].tomatrix() == Matrix([[14, 15, 16, 17]])
-    assert sd[0, 1:3, :].tomatrix() == Matrix([[14, 15, 16, 17], [18, 19, 20, 21]])
-    assert sd[:, :, :] == sd
-
-
-def test_diff_and_applyfunc():
-    from sympy.abc import x, y, z
-    md = ImmutableDenseNDimArray([[x, y], [x*z, x*y*z]])
-    assert md.diff(x) == ImmutableDenseNDimArray([[1, 0], [z, y*z]])
-
-    sd = ImmutableSparseNDimArray(md)
-    assert sd == ImmutableSparseNDimArray([x, y, x*z, x*y*z], (2, 2))
-    assert sd.diff(x) == ImmutableSparseNDimArray([[1, 0], [z, y*z]])
-
-    mdn = md.applyfunc(lambda x: x*3)
-    assert mdn == ImmutableDenseNDimArray([[3*x, 3*y], [3*x*z, 3*x*y*z]])
-    assert md != mdn
-
-    sdn = sd.applyfunc(lambda x: x/2)
-    assert sdn == ImmutableSparseNDimArray([[x/2, y/2], [x*z/2, x*y*z/2]])
-    assert sd != sdn
diff --git a/sympy/tensor/array/tests/test_mutable_ndim_array.py b/sympy/tensor/array/tests/test_mutable_ndim_array.py
index b49e5aefd3..1920ec26db 100644
--- a/sympy/tensor/array/tests/test_mutable_ndim_array.py
+++ b/sympy/tensor/array/tests/test_mutable_ndim_array.py
@@ -238,33 +238,3 @@ def test_higher_dimenions():
     m3_other = MutableDenseNDimArray([[[10, 11, 12, 13], [14, 15, 16, 17], [18, 19, 20, 21]], [[22, 23, 24, 25], [26, 27, 28, 29], [30, 31, 32, 33]]], (2, 3, 4))
 
     assert m3 == m3_other
-
-
-def test_slices():
-    md = MutableDenseNDimArray(range(10, 34), (2, 3, 4))
-
-    assert md[:] == md._array
-    assert md[:, :, 0].tomatrix() == Matrix([[10, 14, 18], [22, 26, 30]])
-    assert md[0, 1:2, :].tomatrix() == Matrix([[14, 15, 16, 17]])
-    assert md[0, 1:3, :].tomatrix() == Matrix([[14, 15, 16, 17], [18, 19, 20, 21]])
-    assert md[:, :, :] == md
-
-    sd = MutableSparseNDimArray(range(10, 34), (2, 3, 4))
-    assert sd == MutableSparseNDimArray(md)
-
-    assert sd[:] == md._array
-    assert sd[:] == list(sd)
-    assert sd[:, :, 0].tomatrix() == Matrix([[10, 14, 18], [22, 26, 30]])
-    assert sd[0, 1:2, :].tomatrix() == Matrix([[14, 15, 16, 17]])
-    assert sd[0, 1:3, :].tomatrix() == Matrix([[14, 15, 16, 17], [18, 19, 20, 21]])
-    assert sd[:, :, :] == sd
-
-
-def test_diff():
-    from sympy.abc import x, y, z
-    md = MutableDenseNDimArray([[x, y], [x*z, x*y*z]])
-    assert md.diff(x) == MutableDenseNDimArray([[1, 0], [z, y*z]])
-
-    sd = MutableSparseNDimArray(md)
-    assert sd == MutableSparseNDimArray([x, y, x*z, x*y*z], (2, 2))
-    assert sd.diff(x) == MutableSparseNDimArray([[1, 0], [z, y*z]])