Repository: sympy/sympy

Issue:
Add a test for `Interval(..) in Interval(..) == False`

Discussion:

Patch:
diff --git a/sympy/core/basic.py b/sympy/core/basic.py
index d8dec8588a..502a3adb8e 100644
--- a/sympy/core/basic.py
+++ b/sympy/core/basic.py
@@ -849,20 +849,15 @@ def subs(self, *args, **kwargs):
 
         sequence = list(sequence)
         for i in range(len(sequence)):
-            s = list(sequence[i])
-            for j, si in enumerate(s):
-                try:
-                    si = sympify(si, strict=True)
-                except SympifyError:
-                    if type(si) is str:
-                        si = Symbol(si)
-                    else:
-                        # if it can't be sympified, skip it
-                        sequence[i] = None
-                        break
-                s[j] = si
-            else:
-                sequence[i] = None if _aresame(*s) else tuple(s)
+            o, n = sequence[i]
+            so, sn = sympify(o), sympify(n)
+            if not isinstance(so, Basic):
+                if type(o) is str:
+                    so = Symbol(o)
+            sequence[i] = (so, sn)
+            if _aresame(so, sn):
+                sequence[i] = None
+                continue
         sequence = list(filter(None, sequence))
 
         if unordered:
diff --git a/sympy/physics/vector/vector.py b/sympy/physics/vector/vector.py
index 93dc3d24c3..e835c3999f 100644
--- a/sympy/physics/vector/vector.py
+++ b/sympy/physics/vector/vector.py
@@ -128,10 +128,7 @@ def __eq__(self, other):
 
         if other == 0:
             other = Vector(0)
-        try:
-            other = _check_vector(other)
-        except TypeError:
-            return False
+        other = _check_vector(other)
         if (self.args == []) and (other.args == []):
             return True
         elif (self.args == []) or (other.args == []):
diff --git a/sympy/solvers/ode.py b/sympy/solvers/ode.py
index aee9f8361b..4cff01f78e 100644
--- a/sympy/solvers/ode.py
+++ b/sympy/solvers/ode.py
@@ -1959,17 +1959,17 @@ def _sympify(eq):
     t = funcs[0].args[0]
     dictsol = dict()
     for sol in sols:
-        func = list(sol.atoms(AppliedUndef))[0]
-        if sol.rhs == func:
-            sol = sol.reversed
-        solved = sol.lhs == func and not sol.rhs.has(func)
-        if not solved:
-            rhs = solve(sol, func)
-            if not rhs:
+        sol_func = list(sol.atoms(AppliedUndef))[0]
+        if not (sol.lhs == sol_func and not sol.rhs.has(sol_func)) and not (\
+        sol.rhs == sol_func and not sol.lhs.has(sol_func)):
+            solved = solve(sol, sol_func)
+            if not solved:
                 raise NotImplementedError
-        else:
-            rhs = sol.rhs
-        dictsol[func] = rhs
+            dictsol[sol_func] = solved
+        if sol.lhs == sol_func:
+            dictsol[sol_func] = sol.rhs
+        if sol.rhs == sol_func:
+            dictsol[sol_func] = sol.lhs
     checkeq = []
     for eq in eqs:
         for func in funcs:
@@ -2243,13 +2243,15 @@ def checkodesol(ode, sol, func=None, order='auto', solve_for_func=True):
         order = ode_order(ode, func)
     solved = sol.lhs == func and not sol.rhs.has(func)
     if solve_for_func and not solved:
-        rhs = solve(sol, func)
-        if rhs:
-            eqs = [Eq(func, t) for t in rhs]
-            if len(rhs) == 1:
-                eqs = eqs[0]
-            return checkodesol(ode, eqs, order=order,
-                solve_for_func=False)
+        solved = solve(sol, func)
+        if solved:
+            if len(solved) == 1:
+                result = checkodesol(ode, Eq(func, solved[0]),
+                    order=order, solve_for_func=False)
+            else:
+                result = checkodesol(ode, [Eq(func, t) for t in solved],
+                order=order, solve_for_func=False)
+            return result
 
     s = True
     testnum = 0
diff --git a/sympy/solvers/solveset.py b/sympy/solvers/solveset.py
index 28ade30649..9f413e43cb 100644
--- a/sympy/solvers/solveset.py
+++ b/sympy/solvers/solveset.py
@@ -363,7 +363,7 @@ def _solve_as_rational(f, symbol, domain):
         return valid_solns - invalid_solns
 
 
-def _solve_trig(f, symbol, domain):
+def _solve_real_trig(f, symbol):
     """ Helper to solve trigonometric equations """
     f = trigsimp(f)
     f_original = f
@@ -379,9 +379,8 @@ def _solve_trig(f, symbol, domain):
     solns = solveset_complex(g, y) - solveset_complex(h, y)
 
     if isinstance(solns, FiniteSet):
-        result = Union(*[invert_complex(exp(I*symbol), s, symbol)[1]
+        return Union(*[invert_complex(exp(I*symbol), s, symbol)[1]
                        for s in solns])
-        return Intersection(result, domain)
     elif solns is S.EmptySet:
         return S.EmptySet
     else:
@@ -575,7 +574,7 @@ def _solveset(f, symbol, domain, _check=False):
         result = Union(*[solver(m, symbol) for m in f.args])
     elif _is_function_class_equation(TrigonometricFunction, f, symbol) or \
             _is_function_class_equation(HyperbolicFunction, f, symbol):
-        result = _solve_trig(f, symbol, domain)
+        result = _solve_real_trig(f, symbol)
     elif f.is_Piecewise:
         dom = domain
         result = EmptySet()


Test patch:
diff --git a/sympy/core/tests/test_subs.py b/sympy/core/tests/test_subs.py
index 3faf17b3a4..73238f0289 100644
--- a/sympy/core/tests/test_subs.py
+++ b/sympy/core/tests/test_subs.py
@@ -622,14 +622,14 @@ def test_mul2():
 
 def test_noncommutative_subs():
     x,y = symbols('x,y', commutative=False)
-    assert (x*y*x).subs([(x, x*y), (y, x)], simultaneous=True) == (x*y*x**2*y)
+    assert (x*y*x).subs([(x,x*y),(y,x)],simultaneous=True) == (x*y*x**2*y)
 
 
 def test_issue_2877():
     f = Float(2.0)
     assert (x + f).subs({f: 2}) == x + 2
 
-    def r(a, b, c):
+    def r(a,b,c):
         return factor(a*x**2 + b*x + c)
     e = r(5/6, 10, 5)
     assert nsimplify(e) == 5*x**2/6 + 10*x + 5
@@ -678,15 +678,3 @@ def test_RootOf_issue_10092():
     eq = x**3 - 17*x**2 + 81*x - 118
     r = RootOf(eq, 0)
     assert (x < r).subs(x, r) is S.false
-
-
-def test_issue_8886():
-    from sympy.physics.mechanics import ReferenceFrame as R
-    from sympy.abc import x
-    # if something can't be sympified we assume that it
-    # doesn't play well with SymPy and disallow the
-    # substitution
-    v = R('A').x
-    assert x.subs(x, v) == x
-    assert v.subs(v, x) == v
-    assert v.__eq__(x) is False
diff --git a/sympy/functions/elementary/tests/test_hyperbolic.py b/sympy/functions/elementary/tests/test_hyperbolic.py
index 46bf4efbc7..5341dd92d0 100644
--- a/sympy/functions/elementary/tests/test_hyperbolic.py
+++ b/sympy/functions/elementary/tests/test_hyperbolic.py
@@ -539,8 +539,8 @@ def test_asech():
     assert asech(2/sqrt(2 + sqrt(2))) == acosh(sqrt(2 + sqrt(2))/2)
     assert asech(S(2)) == acosh(1/S(2))
 
-    # asech(x) == I*acos(1/x)
-    # (Note: the exact formula is asech(x) == +/- I*acos(1/x))
+    # asech(x) == I*acos(x)
+    # (Note: the exact formula is asech(x) == +/- I*acos(x))
     assert asech(-sqrt(2)) == I*acos(-1/sqrt(2))
     assert asech(-2/sqrt(3)) == I*acos(-sqrt(3)/2)
     assert asech(-S(2)) == I*acos(-S.Half)
diff --git a/sympy/sets/tests/test_sets.py b/sympy/sets/tests/test_sets.py
index fa9fedafaf..d112a25476 100644
--- a/sympy/sets/tests/test_sets.py
+++ b/sympy/sets/tests/test_sets.py
@@ -423,6 +423,8 @@ def test_contains():
     assert Interval(0, 2, True, True).contains(0) is S.false
     assert Interval(0, 2, True, True).contains(2) is S.false
 
+    assert (Interval(0, 2) in Interval(0, 2)) is False
+
     assert FiniteSet(1, 2, 3).contains(2) is S.true
     assert FiniteSet(1, 2, Symbol('x')).contains(Symbol('x')) is S.true
 
diff --git a/sympy/solvers/tests/test_solveset.py b/sympy/solvers/tests/test_solveset.py
index 83fc70b391..7af972fcdd 100644
--- a/sympy/solvers/tests/test_solveset.py
+++ b/sympy/solvers/tests/test_solveset.py
@@ -737,7 +737,9 @@ def test_solve_trig():
 
     y, a = symbols('y,a')
     assert solveset(sin(y + a) - sin(y), a, domain=S.Reals) == \
-        imageset(Lambda(n, 2*n*pi), S.Integers)
+        Union(imageset(Lambda(n, 2*n*pi), S.Integers),
+        imageset(Lambda(n,
+        -I*(I*(2*n*pi +arg(-exp(-2*I*y))) + 2*im(y))), S.Integers))
 
 
 @XFAIL