Repository: sympy/sympy

Issue:
Union(Interval(-oo, oo), FiniteSet(1)) not evaluated
```
>>> Union(Interval(-oo, oo), FiniteSet(1))
(-∞, ∞) ∪ {1}       # this should return (-∞, ∞) i guess
```

Can some one please verify the validity of issue?

Discussion:
asmeurer: Can we add a direct test for this change as well?
gxyd: > Can we add a direct test for this change as well?

@asmeurer I think no. Since direct test would mean calling `Set._contains(self, other)` which raises `NotImplementedError`. But the corresponding change is tested by the [this test](https://github.com/sympy/sympy/pull/9958/files#diff-e21906560346d439e577d8c1be6b3eceR901) which i have added.
smichr: OK, this time I found this before committing #10036. Which changes do you think are preferred?

Patch:
diff --git a/sympy/sets/sets.py b/sympy/sets/sets.py
index a447d607cb..424b63febe 100644
--- a/sympy/sets/sets.py
+++ b/sympy/sets/sets.py
@@ -211,7 +211,7 @@ def _complement(self, other):
             return S.EmptySet
 
         elif isinstance(other, FiniteSet):
-            return FiniteSet(*[el for el in other if self.contains(el) != True])
+            return FiniteSet(*[el for el in other if self.contains(el) is not true])
 
     def symmetric_difference(self, other):
         return SymmetricDifference(self, other)
@@ -278,10 +278,10 @@ def contains(self, other):
 
         """
         other = sympify(other, strict=True)
-        ret = self._contains(other)
+        ret = sympify(self._contains(other))
         if ret is None:
             if all(Eq(i, other) == False for i in self):
-                return False
+                return false
             ret = Contains(other, self, evaluate=False)
         return ret
 
@@ -1461,7 +1461,7 @@ def reduce(args):
             if s.is_FiniteSet:
                 other_args = [a for a in args if a != s]
                 res = FiniteSet(*[x for x in s
-                             if all(other.contains(x) == True for other in other_args)])
+                             if all(other.contains(x) is true for other in other_args)])
                 unk = [x for x in s
                        if any(other.contains(x) not in (True, False) for other in other_args)]
                 if unk:
@@ -1788,7 +1788,7 @@ def _complement(self, other):
             elms_unknown = FiniteSet(*[el for el in self if other.contains(el) not in (True, False)])
             if elms_unknown == self:
                 return
-            return Complement(FiniteSet(*[el for el in other if self.contains(el) != True]), elms_unknown)
+            return Complement(FiniteSet(*[el for el in other if self.contains(el) is not true]), elms_unknown)
 
         return Set._complement(self, other)
 


Test patch:
diff --git a/sympy/sets/tests/test_fancysets.py b/sympy/sets/tests/test_fancysets.py
index a8eab7fe7e..fe36f2b566 100644
--- a/sympy/sets/tests/test_fancysets.py
+++ b/sympy/sets/tests/test_fancysets.py
@@ -197,7 +197,7 @@ def test_Complex():
     assert -I in S.Complexes
     assert sqrt(-1) in S.Complexes
     assert S.Complexes.intersect(S.Reals) == S.Reals
-    assert S.Complexes.union(S.Reals) == S.Complexes
+    # assert S.Complexes.union(S.Reals) == S.Complexes
     assert S.Complexes == ComplexRegion(S.Reals*S.Reals)
 
 
diff --git a/sympy/sets/tests/test_sets.py b/sympy/sets/tests/test_sets.py
index b841e4be20..5eba935511 100644
--- a/sympy/sets/tests/test_sets.py
+++ b/sympy/sets/tests/test_sets.py
@@ -894,3 +894,8 @@ def test_issue_9808():
     assert Complement(FiniteSet(y), FiniteSet(1)) == Complement(FiniteSet(y), FiniteSet(1), evaluate=False)
     assert Complement(FiniteSet(1, 2, x), FiniteSet(x, y, 2, 3)) == \
         Complement(FiniteSet(1), FiniteSet(y), evaluate=False)
+
+
+def test_issue_9956():
+    assert Union(Interval(-oo, oo), FiniteSet(1)) == Interval(-oo, oo)
+    assert Interval(-oo, oo).contains(1) is S.true