Repository: sympy/sympy

Issue:
`nfloat` changes the arguments inside `Max`.
It seems that `nfloat` applied to the product of `Max(symbol, number)` function and another expression changes `number -> 1.0` if `number <= 0`.
Is it me misunderstanding the documentation ?

|expr|result|expected ?|
|:---|:-----|----------|
|`nfloat(Max(y, 0))`|`Max(0, y)`|yes|
|`nfloat(x * Max(y, 0))`|`x*Max(1.0, y)`|no|
|`nfloat(Max(y, -1.1))`|`Max(-1.1, y)`|yes|
|`nfloat(x * Max(y, -1.1))`|`x*Max(1.0, y)`|no|
|`nfloat(Max(y, 1.1))`|`Max(1.1, y)`|yes|
|`nfloat(x * Max(y, 1.1))`|`x*Max(1.1, y)`|yes|

```python
from sympy.functions.elementary.miscellaneous import Max
from sympy import nfloat, symbols

x, y, z = symbols('x y z')
```

Discussion:

Patch:
diff --git a/doc/src/modules/solvers/solveset.rst b/doc/src/modules/solvers/solveset.rst
index a3f93dcfb5..025248d570 100644
--- a/doc/src/modules/solvers/solveset.rst
+++ b/doc/src/modules/solvers/solveset.rst
@@ -398,7 +398,7 @@ How does ``solveset`` ensure that it is not returning any wrong solution?
     >>> from sympy import symbols, S, pprint, solveset
     >>> x, n = symbols('x, n')
     >>> pprint(solveset(abs(x) - n, x, domain=S.Reals), use_unicode=True)
-    [0, ∞) ∩ {n}
+    ([0, ∞) ∩ {n}) ∪ ((-∞, 0] ∩ {-n})
 
  Though, there still a lot of work needs to be done in this regard.
 
diff --git a/sympy/assumptions/refine.py b/sympy/assumptions/refine.py
index 612ae724df..14b2f2904f 100644
--- a/sympy/assumptions/refine.py
+++ b/sympy/assumptions/refine.py
@@ -30,7 +30,7 @@ def refine(expr, assumptions=True):
         # TODO: this will probably not work with Integral or Polynomial
         expr = expr.func(*args)
     if hasattr(expr, '_eval_refine'):
-        ref_expr = expr._eval_refine(assumptions)
+        ref_expr = expr._eval_refine()
         if ref_expr is not None:
             return ref_expr
     name = expr.__class__.__name__
diff --git a/sympy/core/evalf.py b/sympy/core/evalf.py
index ed767caf38..9e75733a05 100644
--- a/sympy/core/evalf.py
+++ b/sympy/core/evalf.py
@@ -1281,19 +1281,20 @@ def evalf(x, prec, options):
             # Fall back to ordinary evalf if possible
             if 'subs' in options:
                 x = x.subs(evalf_subs(prec, options['subs']))
-            re, im = x._eval_evalf(prec).as_real_imag()
+            xe = x._eval_evalf(prec)
+            re, im = xe.as_real_imag()
             if re.has(re_) or im.has(im_):
                 raise NotImplementedError
             if re == 0:
                 re = None
                 reprec = None
-            else:
+            elif re.is_number:
                 re = re._to_mpmath(prec, allow_ints=False)._mpf_
                 reprec = prec
             if im == 0:
                 im = None
                 imprec = None
-            else:
+            elif im.is_number:
                 im = im._to_mpmath(prec, allow_ints=False)._mpf_
                 imprec = prec
             r = re, im, reprec, imprec
diff --git a/sympy/core/numbers.py b/sympy/core/numbers.py
index 43c8e7c5a5..765b546b28 100644
--- a/sympy/core/numbers.py
+++ b/sympy/core/numbers.py
@@ -1587,11 +1587,34 @@ def factors(self, limit=None, use_trial=True, use_rho=False,
         smaller than limit (or cheap to compute). Special methods of
         factoring are disabled by default so that only trial division is used.
         """
-        from sympy.ntheory import factorrat
+        from sympy.ntheory import factorint
 
-        return factorrat(self, limit=limit, use_trial=use_trial,
+        f = factorint(self.p, limit=limit, use_trial=use_trial,
                       use_rho=use_rho, use_pm1=use_pm1,
                       verbose=verbose).copy()
+        f = defaultdict(int, f)
+        for p, e in factorint(self.q, limit=limit,
+                              use_trial=use_trial,
+                              use_rho=use_rho,
+                              use_pm1=use_pm1,
+                              verbose=verbose).items():
+            f[p] += -e
+
+        if len(f) > 1 and 1 in f:
+            del f[1]
+        if not f:
+            f = {1: 1}
+        if not visual:
+            return dict(f)
+        else:
+            if -1 in f:
+                f.pop(-1)
+                args = [S.NegativeOne]
+            else:
+                args = []
+            args.extend([Pow(*i, evaluate=False)
+                         for i in sorted(f.items())])
+            return Mul(*args, evaluate=False)
 
     @_sympifyit('other', NotImplemented)
     def gcd(self, other):
@@ -2275,8 +2298,7 @@ def factors(limit=None, use_trial=True, use_rho=False, use_pm1=False,
                 verbose=False, visual=False):
         if visual:
             return S.One
-        else:
-            return {}
+        return {1: 1}
 
 
 class NegativeOne(with_metaclass(Singleton, IntegerConstant)):
diff --git a/sympy/core/operations.py b/sympy/core/operations.py
index 30b1fcb74d..a0869f8459 100644
--- a/sympy/core/operations.py
+++ b/sympy/core/operations.py
@@ -304,32 +304,36 @@ def _eval_evalf(self, prec):
         walks the args of the non-number part recursively (doing the same
         thing).
         """
-        from sympy import Symbol
-        from sympy.core.function import AppliedUndef
-        x, tail = self.as_independent(Symbol, AppliedUndef)
-
-        # if x is an AssocOp Function then the _evalf below will
-        # call _eval_evalf (here) so we must break the recursion
-        if not (tail is self.identity or
-                isinstance(x, AssocOp) and x.is_Function):
-            # here, we have a number so we just call to _evalf with prec;
-            # prec is not the same as n, it is the binary precision so
-            # that's why we don't call to evalf.
-            x = x._evalf(prec) if x is not self.identity else self.identity
-            args = []
-            for a in self.func.make_args(tail):
-                # here we call to _eval_evalf since we don't know what we
-                # are dealing with and all other _eval_evalf routines should
-                # be doing the same thing (i.e. taking binary prec and
-                # finding the evalf-able args)
-                newa = a._eval_evalf(prec)
-                if newa is None:
-                    args.append(a)
-                else:
-                    args.append(newa)
-            if not _aresame(tuple(args), self.func.make_args(tail)):
-                tail = self.func(*args)
-            return self.func(x, tail)
+        from .add import Add
+        from .mul import Mul
+        from .symbol import Symbol
+        from .function import AppliedUndef
+        if isinstance(self, (Mul, Add)):
+            x, tail = self.as_independent(Symbol, AppliedUndef)
+            # if x is an AssocOp Function then the _evalf below will
+            # call _eval_evalf (here) so we must break the recursion
+            if not (tail is self.identity or
+                    isinstance(x, AssocOp) and x.is_Function or
+                    x is self.identity and isinstance(tail, AssocOp)):
+                # here, we have a number so we just call to _evalf with prec;
+                # prec is not the same as n, it is the binary precision so
+                # that's why we don't call to evalf.
+                x = x._evalf(prec) if x is not self.identity else self.identity
+                args = []
+                tail_args = tuple(self.func.make_args(tail))
+                for a in tail_args:
+                    # here we call to _eval_evalf since we don't know what we
+                    # are dealing with and all other _eval_evalf routines should
+                    # be doing the same thing (i.e. taking binary prec and
+                    # finding the evalf-able args)
+                    newa = a._eval_evalf(prec)
+                    if newa is None:
+                        args.append(a)
+                    else:
+                        args.append(newa)
+                if not _aresame(tuple(args), tail_args):
+                    tail = self.func(*args)
+                return self.func(x, tail)
 
         # this is the same as above, but there were no pure-number args to
         # deal with
diff --git a/sympy/core/power.py b/sympy/core/power.py
index 3eaa577d84..3b7d7fad26 100644
--- a/sympy/core/power.py
+++ b/sympy/core/power.py
@@ -220,13 +220,12 @@ def exp(self):
     def class_key(cls):
         return 3, 2, cls.__name__
 
-    def _eval_refine(self, assumptions):
-        from sympy.assumptions.ask import ask, Q
+    def _eval_refine(self):
         b, e = self.as_base_exp()
-        if ask(Q.integer(e), assumptions) and _coeff_isneg(b):
-            if ask(Q.even(e), assumptions):
+        if e.is_integer and _coeff_isneg(b):
+            if e.is_even:
                 return Pow(-b, e)
-            elif ask(Q.odd(e), assumptions):
+            elif e.is_odd:
                 return -Pow(-b, e)
 
     def _eval_power(self, other):
diff --git a/sympy/core/relational.py b/sympy/core/relational.py
index 10e984362c..136e305b93 100644
--- a/sympy/core/relational.py
+++ b/sympy/core/relational.py
@@ -8,7 +8,7 @@
 from .sympify import _sympify
 from .evaluate import global_evaluate
 
-from sympy.logic.boolalg import Boolean, BooleanAtom
+from sympy.logic.boolalg import Boolean
 
 __all__ = (
     'Rel', 'Eq', 'Ne', 'Lt', 'Le', 'Gt', 'Ge',
@@ -310,10 +310,6 @@ def __new__(cls, lhs, rhs=0, **options):
                 if r is not None:
                     return _sympify(r)
 
-            # If expression have both Boolean terms
-            if all(isinstance(i, BooleanAtom) for i in (rhs, lhs)):
-                return S.false  # equal args already evaluated
-
         return Relational.__new__(cls, lhs, rhs, **options)
 
     @classmethod
diff --git a/sympy/functions/elementary/exponential.py b/sympy/functions/elementary/exponential.py
index 6499c40fa7..6bdb6d732e 100644
--- a/sympy/functions/elementary/exponential.py
+++ b/sympy/functions/elementary/exponential.py
@@ -205,7 +205,7 @@ def fdiff(self, argindex=1):
         else:
             raise ArgumentIndexError(self, argindex)
 
-    def _eval_refine(self, assumptions):
+    def _eval_refine(self):
         from sympy.assumptions import ask, Q
         arg = self.args[0]
         if arg.is_Mul:
diff --git a/sympy/ntheory/__init__.py b/sympy/ntheory/__init__.py
index 808a01cc5b..ccec05575c 100644
--- a/sympy/ntheory/__init__.py
+++ b/sympy/ntheory/__init__.py
@@ -7,7 +7,7 @@
 from .primetest import isprime
 from .factor_ import divisors, factorint, multiplicity, perfect_power, \
     pollard_pm1, pollard_rho, primefactors, totient, trailing, divisor_count, \
-    divisor_sigma, factorrat
+    divisor_sigma
 from .partitions_ import npartitions
 from .residue_ntheory import is_primitive_root, is_quad_residue, \
     legendre_symbol, jacobi_symbol, n_order, sqrt_mod, quadratic_residues, \
diff --git a/sympy/ntheory/factor_.py b/sympy/ntheory/factor_.py
index 9242120dfd..f9aab9867d 100644
--- a/sympy/ntheory/factor_.py
+++ b/sympy/ntheory/factor_.py
@@ -1171,58 +1171,6 @@ def factorint(n, limit=None, use_trial=True, use_rho=True, use_pm1=True,
         low, high = high, high*2
 
 
-def factorrat(rat, limit=None, use_trial=True, use_rho=True, use_pm1=True,
-              verbose=False, visual=None):
-    r"""
-    Given a Rational ``r``, ``factorrat(r)`` returns a dict containing
-    the prime factors of ``r`` as keys and their respective multiplicities
-    as values. For example:
-
-    >>> from sympy.ntheory import factorrat
-    >>> from sympy.core.symbol import S
-    >>> factorrat(S(8)/9)    # 8/9 = (2**3) * (3**-2)
-    {2: 3, 3: -2}
-    >>> factorrat(S(-1)/987)    # -1/789 = -1 * (3**-1) * (7**-1) * (47**-1)
-    {-1: 1, 3: -1, 7: -1, 47: -1}
-
-    Please see the docstring for ``factorint`` for detailed explanations
-    and examples of the following keywords:
-
-        - ``limit``: Integer limit up to which trial division is done
-        - ``use_trial``: Toggle use of trial division
-        - ``use_rho``: Toggle use of Pollard's rho method
-        - ``use_pm1``: Toggle use of Pollard's p-1 method
-        - ``verbose``: Toggle detailed printing of progress
-        - ``visual``: Toggle product form of output
-    """
-    from collections import defaultdict
-    f = factorint(rat.p, limit=limit, use_trial=use_trial,
-                  use_rho=use_rho, use_pm1=use_pm1,
-                  verbose=verbose).copy()
-    f = defaultdict(int, f)
-    for p, e in factorint(rat.q, limit=limit,
-                          use_trial=use_trial,
-                          use_rho=use_rho,
-                          use_pm1=use_pm1,
-                          verbose=verbose).items():
-        f[p] += -e
-
-    if len(f) > 1 and 1 in f:
-        del f[1]
-    if not visual:
-        return dict(f)
-    else:
-        if -1 in f:
-            f.pop(-1)
-            args = [S.NegativeOne]
-        else:
-            args = []
-        args.extend([Pow(*i, evaluate=False)
-                     for i in sorted(f.items())])
-        return Mul(*args, evaluate=False)
-
-
-
 def primefactors(n, limit=None, verbose=False):
     """Return a sorted list of n's prime factors, ignoring multiplicity
     and any composite factor that remains if the limit was set too low
diff --git a/sympy/physics/units.py b/sympy/physics/units.py
index f73c0d558d..9a40fd872e 100644
--- a/sympy/physics/units.py
+++ b/sympy/physics/units.py
@@ -222,7 +222,6 @@ def free_symbols(self):
 h = hour = hours = 60*minute
 day = days = 24*hour
 
-anomalistic_year = anomalistic_years = Rational('365.259636')*day
 sidereal_year = sidereal_years = Rational('31558149.540')*s
 tropical_year = tropical_years = Rational('365.24219')*day
 common_year = common_years = Rational('365')*day
diff --git a/sympy/release.py b/sympy/release.py
index e9dbd439e6..0573d92582 100644
--- a/sympy/release.py
+++ b/sympy/release.py
@@ -1,1 +1,1 @@
-__version__ = "1.0.1.dev"
+__version__ = "0.7.7.dev"
diff --git a/sympy/sets/sets.py b/sympy/sets/sets.py
index fb3cee8d95..9d4c10466e 100644
--- a/sympy/sets/sets.py
+++ b/sympy/sets/sets.py
@@ -12,7 +12,7 @@
 from sympy.core.evaluate import global_evaluate
 from sympy.core.mul import Mul
 from sympy.core.relational import Eq
-from sympy.core.symbol import Symbol, Dummy
+from sympy.core.symbol import Symbol
 from sympy.sets.contains import Contains
 from sympy.utilities.misc import func_name
 
@@ -1426,21 +1426,23 @@ def __iter__(self):
     def _handle_finite_sets(args):
         from sympy.core.logic import fuzzy_and, fuzzy_bool
         from sympy.core.compatibility import zip_longest
-        from sympy.utilities.iterables import sift
 
-        sifted = sift(args, lambda x: x.is_FiniteSet)
-        fs_args = sifted.pop(True, [])
+        new_args = []
+        fs_args = []
+        for s in args:
+            if s.is_FiniteSet:
+                fs_args.append(s)
+            else:
+                new_args.append(s)
         if not fs_args:
             return
         s = fs_args[0]
         fs_args = fs_args[1:]
-        other = sifted.pop(False, [])
-
         res = []
         unk = []
         for x in s:
             c = fuzzy_and(fuzzy_bool(o.contains(x))
-                for o in fs_args + other)
+                for o in fs_args + new_args)
             if c:
                 res.append(x)
             elif c is None:
@@ -1472,13 +1474,13 @@ def _handle_finite_sets(args):
                     contained = [x for x in symbolic_s_list
                         if sympify(v.contains(x)) is S.true]
                     if contained != symbolic_s_list:
-                        other.append(
+                        new_args.append(
                             v - FiniteSet(
                             *contained, evaluate=False))
                     else:
                         pass  # for coverage
 
-            other_sets = Intersection(*other)
+            other_sets = Intersection(*new_args)
             if not other_sets:
                 return S.EmptySet  # b/c we use evaluate=False below
             res += Intersection(
@@ -1489,15 +1491,14 @@ def _handle_finite_sets(args):
     @staticmethod
     def reduce(args):
         """
-        Return a simplified intersection by applying rules.
+        Simplify an intersection using known rules
 
         We first start with global rules like
-        'if any empty sets, return empty set' and 'distribute unions'.
+        'if any empty sets return empty set' and 'distribute any unions'
 
         Then we iterate through all pairs and ask the constituent sets if they
         can simplify themselves with any other constituent
         """
-        from sympy.simplify.simplify import clear_coefficients
 
         # ===== Global Rules =====
         # If any EmptySets return EmptySet
@@ -1507,22 +1508,6 @@ def reduce(args):
         # Handle Finite sets
         rv = Intersection._handle_finite_sets(args)
         if rv is not None:
-            # simplify symbolic intersection between a FiniteSet
-            # and an interval
-            if isinstance(rv, Intersection) and len(rv.args) == 2:
-                ivl, s = rv.args
-                if isinstance(s, FiniteSet) and len(s) == 1 and isinstance(ivl, Interval):
-                    e = list(s)[0]
-                    if e.free_symbols:
-                        rhs = Dummy()
-                        e, r = clear_coefficients(e, rhs)
-                        if r != rhs:
-                            iargs = list(ivl.args)
-                            iargs[0] = r.subs(rhs, ivl.start)
-                            iargs[1] = r.subs(rhs, ivl.end)
-                            if iargs[0] > iargs[1]:
-                                iargs = iargs[:2][::-1] + iargs[-2:][::-1]
-                            rv = Intersection(FiniteSet(e), Interval(*iargs), evaluate=False)
             return rv
 
         # If any of the sets are unions, return a Union of Intersections
diff --git a/sympy/simplify/simplify.py b/sympy/simplify/simplify.py
index 4b78039c56..2b9643de7e 100644
--- a/sympy/simplify/simplify.py
+++ b/sympy/simplify/simplify.py
@@ -9,7 +9,7 @@
 from sympy.core.compatibility import (iterable,
     ordered, range, as_int)
 from sympy.core.numbers import Float, I, pi, Rational, Integer
-from sympy.core.function import expand_log, count_ops, _mexpand, _coeff_isneg
+from sympy.core.function import expand_log, count_ops, _mexpand
 from sympy.core.rules import Transform
 from sympy.core.evaluate import global_evaluate
 from sympy.functions import (
@@ -1257,48 +1257,3 @@ def _real_to_rational(expr, tolerance=None):
                     r = Integer(0)
         reps[key] = r
     return p.subs(reps, simultaneous=True)
-
-
-def clear_coefficients(expr, rhs=S.Zero):
-    """Return `p, r` where `p` is the expression obtained when Rational
-    additive and multiplicative coefficients of `expr` have been stripped
-    away in a naive fashion (i.e. without simplification). The operations
-    needed to remove the coefficients will be applied to `rhs` and returned
-    as `r`.
-
-    Examples
-    ========
-
-    >>> from sympy.simplify.simplify import clear_coefficients
-    >>> from sympy.abc import x, y
-    >>> from sympy import Dummy
-    >>> expr = 4*y*(6*x + 3)
-    >>> clear_coefficients(expr - 2)
-    (y*(2*x + 1), 1/6)
-
-    When solving 2 or more expressions like `expr = a`,
-    `expr = b`, etc..., it is advantageous to provide a Dummy symbol
-    for `rhs` and  simply replace it with `a`, `b`, etc... in `r`.
-
-    >>> rhs = Dummy('rhs')
-    >>> clear_coefficients(expr, rhs)
-    (y*(2*x + 1), _rhs/12)
-    >>> _[1].subs(rhs, 2)
-    1/6
-    """
-    was = None
-    free = expr.free_symbols
-    while was != expr:
-        was = expr
-        m, expr = (
-            expr.as_content_primitive()
-            if free else
-            factor_terms(expr).as_coeff_Mul())
-        rhs /= m
-        c, expr = expr.as_coeff_Add()
-        rhs -= c
-    expr = signsimp(expr, evaluate = False)
-    if _coeff_isneg(expr):
-        expr = -expr
-        rhs = -rhs
-    return expr, rhs


Test patch:
diff --git a/sympy/assumptions/tests/test_refine.py b/sympy/assumptions/tests/test_refine.py
index 00a16d4195..ce94837680 100644
--- a/sympy/assumptions/tests/test_refine.py
+++ b/sympy/assumptions/tests/test_refine.py
@@ -156,7 +156,7 @@ def my_func(*args):
 def test_eval_refine():
     from sympy.core.expr import Expr
     class MockExpr(Expr):
-        def _eval_refine(self, assumptions):
+        def _eval_refine(self):
             return True
 
     mock_obj = MockExpr()
diff --git a/sympy/core/tests/test_evalf.py b/sympy/core/tests/test_evalf.py
index a1775324d2..5b781713cd 100644
--- a/sympy/core/tests/test_evalf.py
+++ b/sympy/core/tests/test_evalf.py
@@ -1,7 +1,7 @@
-from sympy import (Abs, Add, atan, ceiling, cos, E, Eq, exp, factorial,
-                   fibonacci, floor, Function, GoldenRatio, I, Integral,
-                   integrate, log, Mul, N, oo, pi, Pow, product, Product,
-                   Rational, S, Sum, sin, sqrt, sstr, sympify, Symbol)
+from sympy import (Abs, Add, atan, ceiling, cos, E, Eq, exp,
+    factorial, fibonacci, floor, Function, GoldenRatio, I, Integral,
+    integrate, log, Mul, N, oo, pi, Pow, product, Product,
+    Rational, S, Sum, sin, sqrt, sstr, sympify, Symbol, Max, nfloat)
 from sympy.core.evalf import (complex_accuracy, PrecisionExhausted,
     scaled_zero, get_integer_part, as_mpmath)
 from mpmath import inf, ninf
@@ -495,3 +495,11 @@ def test_AssocOp_Function():
     # should raise a value error because the first arg computes
     # a non-comparable (prec=1) imaginary part
     raises(ValueError, lambda: e._eval_evalf(2))
+
+
+def test_issue_10395():
+    eq = x*Max(0, y)
+    assert nfloat(eq) == eq
+    eq = x*Max(y, -1.1)
+    assert nfloat(eq) == eq
+    assert Max(y, 4).n() == Max(4.0, y)
diff --git a/sympy/core/tests/test_numbers.py b/sympy/core/tests/test_numbers.py
index 4cf49c128b..c434a1406c 100644
--- a/sympy/core/tests/test_numbers.py
+++ b/sympy/core/tests/test_numbers.py
@@ -1097,7 +1097,7 @@ def test_Integer_factors():
     def F(i):
         return Integer(i).factors()
 
-    assert F(1) == {}
+    assert F(1) == {1: 1}
     assert F(2) == {2: 1}
     assert F(3) == {3: 1}
     assert F(4) == {2: 2}
@@ -1158,6 +1158,10 @@ def F(p, q, visual=None):
     assert F(2, 9) == {2: 1, 3: -2}
     assert F(2, 15) == {2: 1, 3: -1, 5: -1}
     assert F(6, 10) == {3: 1, 5: -1}
+    assert str(F(12, 1, visual=True)) == '2**2*3**1'
+    assert str(F(1, 1, visual=True)) == '1'
+    assert str(F(25, 14, visual=True)) == '5**2/(2*7)'
+    assert str(F(-25, 14*9, visual=True)) == '-5**2/(2*3**2*7)'
 
 
 def test_issue_4107():
diff --git a/sympy/core/tests/test_relational.py b/sympy/core/tests/test_relational.py
index 50ecadb032..4309441a6d 100644
--- a/sympy/core/tests/test_relational.py
+++ b/sympy/core/tests/test_relational.py
@@ -661,9 +661,3 @@ def test_issue_10304():
     assert d.is_comparable is False  # if this fails, find a new d
     e = 1 + d*I
     assert simplify(Eq(e, 0)) is S.false
-
-def test_issue_10633():
-    assert Eq(True, False) == False
-    assert Eq(False, True) == False
-    assert Eq(True, True) == True
-    assert Eq(False, False) == True
diff --git a/sympy/ntheory/tests/test_factor_.py b/sympy/ntheory/tests/test_factor_.py
index ac9f3f4de3..851ddf6a53 100644
--- a/sympy/ntheory/tests/test_factor_.py
+++ b/sympy/ntheory/tests/test_factor_.py
@@ -3,7 +3,7 @@
 from sympy.core.compatibility import long, range
 
 from sympy.ntheory import totient, factorint, primefactors, divisors, nextprime, pollard_rho, \
-    perfect_power, multiplicity, trailing, divisor_count, primorial, pollard_pm1, divisor_sigma, factorrat
+    perfect_power, multiplicity, trailing, divisor_count, primorial, pollard_pm1, divisor_sigma
 
 from sympy.ntheory.factor_ import smoothness, smoothness_p, \
     antidivisors, antidivisor_count, core, digits, udivisors, udivisor_sigma, \
@@ -390,13 +390,6 @@ def test_visual_factorint():
     assert -1 in factorint(-42, visual=True).args
 
 
-def test_factorrat():
-    assert str(factorrat(S(12)/1, visual=True)) == '2**2*3**1'
-    assert str(factorrat(S(1)/1, visual=True)) == '1'
-    assert str(factorrat(S(25)/14, visual=True)) == '5**2/(2*7)'
-    assert str(factorrat(S(-25)/14/9, visual=True)) == '-5**2/(2*3**2*7)'
-
-
 def test_visual_io():
     sm = smoothness_p
     fi = factorint
diff --git a/sympy/sets/tests/test_sets.py b/sympy/sets/tests/test_sets.py
index 31334dc8b7..8a9d22c3b8 100644
--- a/sympy/sets/tests/test_sets.py
+++ b/sympy/sets/tests/test_sets.py
@@ -3,7 +3,7 @@
     FiniteSet, Intersection, imageset, I, true, false, ProductSet, E,
     sqrt, Complement, EmptySet, sin, cos, Lambda, ImageSet, pi,
     Eq, Pow, Contains, Sum, rootof, SymmetricDifference, Piecewise,
-    Matrix, signsimp)
+    Matrix)
 from mpmath import mpi
 
 from sympy.core.compatibility import range
@@ -982,18 +982,3 @@ def test_issue_10326():
     assert Interval(1, 2) in FiniteSet(Interval(0, 5), Interval(1, 2))
     assert Interval(-oo, oo).contains(oo) is S.false
     assert Interval(-oo, oo).contains(-oo) is S.false
-
-
-def test_issue_10285():
-    assert FiniteSet(-x - 1).intersect(Interval.Ropen(1, 2)) == \
-        FiniteSet(x).intersect(Interval.Lopen(-3, -2))
-    eq = -x - 2*(-x - y)
-    s = signsimp(eq)
-    ivl = Interval.open(0, 1)
-    assert FiniteSet(eq).intersect(ivl) == FiniteSet(s).intersect(ivl)
-    assert FiniteSet(-eq).intersect(ivl) == \
-        FiniteSet(s).intersect(Interval.open(-1, 0))
-    eq -= 1
-    ivl = Interval.Lopen(1, oo)
-    assert FiniteSet(eq).intersect(ivl) == \
-        FiniteSet(s).intersect(Interval.Lopen(2, oo))
diff --git a/sympy/simplify/tests/test_simplify.py b/sympy/simplify/tests/test_simplify.py
index 63f3a209c6..88c6ebc26f 100644
--- a/sympy/simplify/tests/test_simplify.py
+++ b/sympy/simplify/tests/test_simplify.py
@@ -635,12 +635,3 @@ def inverse(self, argindex=1):
     assert simplify(f(g(x))) == x
     assert simplify(f(g(sin(x)**2 + cos(x)**2))) == 1
     assert simplify(f(g(x, y))) == f(g(x, y))
-
-
-def test_clear_coefficients():
-    from sympy.simplify.simplify import clear_coefficients
-    assert clear_coefficients(4*y*(6*x + 3)) == (y*(2*x + 1), 0)
-    assert clear_coefficients(4*y*(6*x + 3) - 2) == (y*(2*x + 1), S(1)/6)
-    assert clear_coefficients(4*y*(6*x + 3) - 2, x) == (y*(2*x + 1), x/12 + S(1)/6)
-    assert clear_coefficients(sqrt(2) - 2) == (sqrt(2), 2)
-    assert clear_coefficients(4*sqrt(2) - 2) == (sqrt(2), S.Half)
diff --git a/sympy/solvers/tests/test_solveset.py b/sympy/solvers/tests/test_solveset.py
index 7af972fcdd..ee49f9cc72 100644
--- a/sympy/solvers/tests/test_solveset.py
+++ b/sympy/solvers/tests/test_solveset.py
@@ -139,13 +139,19 @@ def ireal(x, s=S.Reals):
     n = Dummy('n')
     x = Symbol('x')
 
-    h1 = Intersection(Interval(-oo, -3), FiniteSet(-a + b - 3),
+    h1 = Intersection(Interval(-3, oo), FiniteSet(a + b - 3),
+                      imageset(Lambda(n, -n + a - 3), Interval(-oo, 0)))
+
+    h2 = Intersection(Interval(-oo, -3), FiniteSet(-a + b - 3),
                       imageset(Lambda(n, n - a - 3), Interval(0, oo)))
 
-    h2 = Intersection(Interval(-3, oo), FiniteSet(a - b - 3),
+    h3 = Intersection(Interval(-3, oo), FiniteSet(a - b - 3),
                       imageset(Lambda(n, -n + a - 3), Interval(0, oo)))
 
-    assert invert_real(Abs(Abs(x + 3) - a) - b, 0, x) == (x, Union(h1, h2))
+    h4 = Intersection(Interval(-oo, -3), FiniteSet(-a - b - 3),
+                      imageset(Lambda(n, n - a - 3), Interval(-oo, 0)))
+
+    assert invert_real(Abs(Abs(x + 3) - a) - b, 0, x) == (x, Union(h1, h2, h3, h4))
 
 
 def test_invert_complex():