Repository: sympy/sympy

Issue:
Addition with Order gives wrong result
`O(x).subs(x,x-1) + 1` results in `O(x - 1, (x, 1))` instead of `cos(1) + O(x - 1, (x, 1))`

This results in a wrong series expantion:

`cos(x).series(x,1,n=1)` results in `O(x - 1, (x, 1))` instead of `1 + O(x - 1, (x, 1))`

See a [question](http://stackoverflow.com/questions/40798077/why-does-my-sympy-code-calculate-the-first-order-taylor-series-approximation-inc/40814600#40814600) on Stack Overflow.


 

Discussion:

Patch:
diff --git a/sympy/calculus/util.py b/sympy/calculus/util.py
index 7174d92c28..c81b77fe5e 100644
--- a/sympy/calculus/util.py
+++ b/sympy/calculus/util.py
@@ -1338,10 +1338,9 @@ def __pow__(self, other):
                                 return AccumBounds(0, real_root(self.max, den))
                     return AccumBounds(real_root(self.min, den),
                                        real_root(self.max, den))
-                if den!=1:
-                    num_pow = self**num
-                    return num_pow**(1 / den)
-            return AccumBounds(-oo, oo)
+                num_pow = self**num
+                return num_pow**(1 / den)
+            return Pow(self, other, evaluate=False)
 
         return NotImplemented
 
diff --git a/sympy/combinatorics/perm_groups.py b/sympy/combinatorics/perm_groups.py
index c25e15c5d7..085005fcb3 100644
--- a/sympy/combinatorics/perm_groups.py
+++ b/sympy/combinatorics/perm_groups.py
@@ -2567,92 +2567,6 @@ def minimal_block(self, points):
         new_reps = {}
         return [new_reps.setdefault(r, i) for i, r in enumerate(parents)]
 
-    def conjugacy_class(self, x):
-        r"""Return the conjugacy class of an element in the group.
-
-        The conjugacy class of an element ``g`` in a group ``G`` is the set of
-        elements ``x`` in ``G`` that are conjugate with ``g``, i.e. for which
-
-            ``g = xax^{-1}``
-
-        for some ``a`` in ``G``.
-
-        Note that conjugacy is an equivalence relation, and therefore that
-        conjugacy classes are partitions of ``G``. For a list of all the
-        conjugacy classes of the group, use the conjugacy_classes() method.
-
-        In a permutation group, each conjugacy class corresponds to a particular
-        `cycle structure': for example, in ``S_3``, the conjugacy classes are:
-
-            * the identity class, ``{()}``
-            * all transpositions, ``{(1 2), (1 3), (2 3)}``
-            * all 3-cycles, ``{(1 2 3), (1 3 2)}``
-
-        Examples
-        ========
-
-        >>> from sympy.combinatorics.permutations import Permutation
-        >>> from sympy.combinatorics.named_groups import SymmetricGroup
-        >>> S3 = SymmetricGroup(3)
-        >>> S3.conjugacy_class(Permutation(0, 1, 2))
-        {(0 1 2), (0 2 1)}
-
-        Notes
-        =====
-
-        This procedure computes the conjugacy class directly by finding the
-        orbit of the element under conjugation in G. This algorithm is only
-        feasible for permutation groups of relatively small order, but is like
-        the orbit() function itself in that respect.
-        """
-        # Ref: "Computing the conjugacy classes of finite groups"; Butler, G.
-        # Groups '93 Galway/St Andrews; edited by Campbell, C. M.
-        new_class = set([x])
-        last_iteration = new_class
-
-        while len(last_iteration) > 0:
-            this_iteration = set()
-
-            for y in last_iteration:
-                for s in self.generators:
-                    conjugated = s * y * (~s)
-                    if conjugated not in new_class:
-                        this_iteration.add(conjugated)
-
-            new_class.update(last_iteration)
-            last_iteration = this_iteration
-
-        return new_class
-
-
-    def conjugacy_classes(self):
-        r"""Return the conjugacy classes of the group.
-
-        As described in the documentation for the .conjugacy_class() function,
-        conjugacy is an equivalence relation on a group G which partitions the
-        set of elements. This method returns a list of all these conjugacy
-        classes of G.
-
-        Examples
-        ========
-
-        >>> from sympy.combinatorics import SymmetricGroup
-        >>> SymmetricGroup(3).conjugacy_classes()
-        [{(2)}, {(0 1 2), (0 2 1)}, {(0 2), (1 2), (2)(0 1)}]
-
-        """
-        identity = _af_new(list(range(self.degree)))
-        known_elements = set([identity])
-        classes = [known_elements.copy()]
-
-        for x in self.generate():
-            if x not in known_elements:
-                new_class = self.conjugacy_class(x)
-                classes.append(new_class)
-                known_elements.update(new_class)
-
-        return classes
-
     def normal_closure(self, other, k=10):
         r"""Return the normal closure of a subgroup/set of permutations.
 
diff --git a/sympy/core/compatibility.py b/sympy/core/compatibility.py
index 0b40c0f843..555c66412a 100644
--- a/sympy/core/compatibility.py
+++ b/sympy/core/compatibility.py
@@ -346,10 +346,10 @@ def as_int(n, strict=True):
     """
     Convert the argument to a builtin integer.
 
-    The return value is guaranteed to be equal to the input. ValueError is
-    raised if the input has a non-integral value. When ``strict`` is True, this
-    uses `__index__ <https://docs.python.org/3/reference/datamodel.html#object.__index__>`_
-    and when it is False it uses ``int``.
+    The return value is guaranteed to be equal to the input. ValueError
+    is raised if the input has a non-integral value. When ``strict`` is
+    False, non-integer input that compares equal to the integer value
+    will not raise an error.
 
 
     Examples
@@ -392,19 +392,16 @@ def as_int(n, strict=True):
     ...
     ValueError: ... is not an integer
     """
-    if strict:
-        try:
-            return operator.index(n)
-        except TypeError:
-            raise ValueError('%s is not an integer' % (n,))
-    else:
-        try:
-            result = int(n)
-        except TypeError:
-            raise ValueError('%s is not an integer' % (n,))
-        if n != result:
-            raise ValueError('%s is not an integer' % (n,))
+    from sympy.core.numbers import Integer
+    try:
+        if strict and not isinstance(n, SYMPY_INTS + (Integer,)):
+            raise TypeError
+        result = int(n)
+        if result != n:
+            raise TypeError
         return result
+    except TypeError:
+        raise ValueError('%s is not an integer' % (n,))
 
 
 def default_sort_key(item, order=None):
diff --git a/sympy/geometry/plane.py b/sympy/geometry/plane.py
index 33a7a8871c..1807ab7045 100644
--- a/sympy/geometry/plane.py
+++ b/sympy/geometry/plane.py
@@ -494,7 +494,7 @@ def is_parallel(self, l):
         elif isinstance(l, Plane):
             a = Matrix(l.normal_vector)
             b = Matrix(self.normal_vector)
-            if a.cross(b).is_zero_matrix:
+            if a.cross(b).is_zero:
                 return True
             else:
                 return False
@@ -527,7 +527,7 @@ def is_perpendicular(self, l):
         if isinstance(l, LinearEntity3D):
             a = Matrix(l.direction_ratio)
             b = Matrix(self.normal_vector)
-            if a.cross(b).is_zero_matrix:
+            if a.cross(b).is_zero:
                 return True
             else:
                 return False
diff --git a/sympy/holonomic/holonomic.py b/sympy/holonomic/holonomic.py
index 9ced290153..7594ef5fda 100644
--- a/sympy/holonomic/holonomic.py
+++ b/sympy/holonomic/holonomic.py
@@ -598,7 +598,7 @@ def __add__(self, other):
 
         # if a solution is not obtained then increasing the order by 1 in each
         # iteration
-        while sol.is_zero_matrix:
+        while sol.is_zero:
             dim += 1
 
             diff1 = (gen * rowsself[-1])
@@ -986,7 +986,7 @@ def __mul__(self, other):
         sol = (NewMatrix(lin_sys).transpose()).gauss_jordan_solve(homo_sys)
 
         # until a non trivial solution is found
-        while sol[0].is_zero_matrix:
+        while sol[0].is_zero:
 
             # updating the coefficients Dx^i(f).Dx^j(g) for next degree
             for i in range(a - 1, -1, -1):
@@ -1211,19 +1211,19 @@ def composition(self, expr, *args, **kwargs):
         homogeneous = Matrix([[S.Zero for i in range(a)]]).transpose()
         sol = S.Zero
 
-        while True:
+        while sol.is_zero:
             coeffs_next = [p.diff(self.x) for p in coeffs]
             for i in range(a - 1):
                 coeffs_next[i + 1] += (coeffs[i] * diff)
+
             for i in range(a):
                 coeffs_next[i] += (coeffs[-1] * subs[i] * diff)
             coeffs = coeffs_next
+
             # check for linear relations
             system.append(coeffs)
             sol, taus = (Matrix(system).transpose()
                 ).gauss_jordan_solve(homogeneous)
-            if sol.is_zero_matrix is not True:
-                break
 
         tau = list(taus)[0]
         sol = sol.subs(tau, 1)
diff --git a/sympy/holonomic/linearsolver.py b/sympy/holonomic/linearsolver.py
index 6eb2e0c97d..5e37e6b35e 100644
--- a/sympy/holonomic/linearsolver.py
+++ b/sympy/holonomic/linearsolver.py
@@ -66,7 +66,7 @@ def gauss_jordan_solve(self, b, freevar=False):
 
         # check for existence of solutions
         # rank of aug Matrix should be equal to rank of coefficient matrix
-        if not v[rank:, 0].is_zero_matrix:
+        if not v[rank:, 0].is_zero:
             raise ValueError("Linear system has no solution")
 
         # Get index of free symbols (free parameters)
diff --git a/sympy/matrices/common.py b/sympy/matrices/common.py
index f5753115ca..4617511626 100644
--- a/sympy/matrices/common.py
+++ b/sympy/matrices/common.py
@@ -1114,7 +1114,7 @@ def _eval_is_diagonal(self):
     # sure the names don't clash by adding `_matrix_` in name.
     def _eval_is_matrix_hermitian(self, simpfunc):
         mat = self._new(self.rows, self.cols, lambda i, j: simpfunc(self[i, j] - self[j, i].conjugate()))
-        return mat.is_zero_matrix
+        return mat.is_zero
 
     def _eval_is_Identity(self) -> FuzzyBool:
         def dirac(i, j):
@@ -1141,9 +1141,9 @@ def _eval_is_symbolic(self):
 
     def _eval_is_symmetric(self, simpfunc):
         mat = self._new(self.rows, self.cols, lambda i, j: simpfunc(self[i, j] - self[j, i]))
-        return mat.is_zero_matrix
+        return mat.is_zero
 
-    def _eval_is_zero_matrix(self):
+    def _eval_is_zero(self):
         if any(i.is_zero == False for i in self):
             return False
         if any(i.is_zero is None for i in self):
@@ -1623,7 +1623,7 @@ def is_upper(self):
                    for j in range(min(i, self.cols)))
 
     @property
-    def is_zero_matrix(self):
+    def is_zero(self):
         """Checks if a matrix is a zero matrix.
 
         A matrix is zero if every element is zero.  A matrix need not be square
@@ -1641,17 +1641,17 @@ def is_zero_matrix(self):
         >>> c = Matrix([[0, 1], [0, 0]])
         >>> d = Matrix([])
         >>> e = Matrix([[x, 0], [0, 0]])
-        >>> a.is_zero_matrix
+        >>> a.is_zero
         True
-        >>> b.is_zero_matrix
+        >>> b.is_zero
         True
-        >>> c.is_zero_matrix
+        >>> c.is_zero
         False
-        >>> d.is_zero_matrix
+        >>> d.is_zero
         True
-        >>> e.is_zero_matrix
+        >>> e.is_zero
         """
-        return self._eval_is_zero_matrix()
+        return self._eval_is_zero()
 
     def values(self):
         """Return non-zero values of self."""
diff --git a/sympy/matrices/dense.py b/sympy/matrices/dense.py
index 8ce9042fce..681d6636d2 100644
--- a/sympy/matrices/dense.py
+++ b/sympy/matrices/dense.py
@@ -787,8 +787,7 @@ def zip_row_op(self, i, k, f):
 
         self._mat[i0: i0 + self.cols] = [f(x, y) for x, y in zip(ri, rk)]
 
-    is_zero = False
-
+    # Utility functions
 
 MutableMatrix = Matrix = MutableDenseMatrix
 
diff --git a/sympy/matrices/expressions/hadamard.py b/sympy/matrices/expressions/hadamard.py
index 06ab396a49..7f13f0cc5f 100644
--- a/sympy/matrices/expressions/hadamard.py
+++ b/sympy/matrices/expressions/hadamard.py
@@ -132,7 +132,7 @@ def _eval_derivative_matrix_lines(self, x):
                                 ExprBuilder(_make_matrix, [l2]),
                             ]
                         ),
-                    *diagonal],
+                    ] + diagonal,  # turn into *diagonal after dropping Python 2.7
 
                 )
                 i._first_pointer_parent = subexpr.args[0].args[0].args
@@ -451,7 +451,7 @@ def _eval_derivative_matrix_lines(self, x):
                             ExprBuilder(_make_matrix, [l2]),
                         ]
                     ),
-                *diagonal],
+                ] + diagonal,  # turn into *diagonal after dropping Python 2.7
                 validator=CodegenArrayDiagonal._validate
             )
             i._first_pointer_parent = subexpr.args[0].args[0].args
diff --git a/sympy/matrices/immutable.py b/sympy/matrices/immutable.py
index 6ab214f68c..841bdb86c6 100644
--- a/sympy/matrices/immutable.py
+++ b/sympy/matrices/immutable.py
@@ -2,7 +2,7 @@
 
 from typing import Callable
 
-from sympy.core import Basic, Dict, Integer, S, Tuple
+from sympy.core import Basic, Dict, Integer, S, Tuple, sympify
 from sympy.core.cache import cacheit
 from sympy.core.sympify import converter as sympify_converter
 from sympy.matrices.dense import DenseMatrix
@@ -91,11 +91,8 @@ def _eval_Eq(self, other):
         if isinstance(other, MatrixExpr) and not isinstance(
                 other, ImmutableDenseMatrix):
             return None
-        diff = (self - other).is_zero_matrix
-        if diff is True:
-            return S.true
-        elif diff is False:
-            return S.false
+        diff = self - other
+        return sympify(diff.is_zero)
 
     def _eval_extract(self, rowsList, colsList):
         # self._mat is a Tuple.  It is slightly faster to index a
@@ -125,6 +122,17 @@ def is_diagonalizable(self, reals_only=False, **kwargs):
     is_diagonalizable = cacheit(is_diagonalizable)
 
 
+# XXX: The assumptions system correctly infers that is_zero is always False
+# because commutative is False and zero is commutative. This assignment of
+# the property has to take place after the class definition so that the
+# ManagedProperties metaclass that handles the assumptions has finished
+# post-processing the class first. This should be removed because a Matrix
+# should always have is_zero=False.
+# https://github.com/sympy/sympy/issues/7213
+# https://github.com/sympy/sympy/issues/17131
+# mypy (correctly) complains about this line:
+ImmutableDenseMatrix.is_zero = DenseMatrix.is_zero  # type: ignore
+
 # make sure ImmutableDenseMatrix is aliased as ImmutableMatrix
 ImmutableMatrix = ImmutableDenseMatrix
 
diff --git a/sympy/matrices/matrices.py b/sympy/matrices/matrices.py
index 71e212789e..dad7eebc6c 100644
--- a/sympy/matrices/matrices.py
+++ b/sympy/matrices/matrices.py
@@ -818,6 +818,9 @@ def __mathml__(self):
             mml += "</matrixrow>"
         return "<matrix>" + mml + "</matrix>"
 
+    # needed for python 2 compatibility
+    def __ne__(self, other):
+        return not self == other
 
     def _diagonal_solve(self, rhs):
         """Helper function of function diagonal_solve, without the error
@@ -1967,7 +1970,7 @@ def gauss_jordan_solve(self, B, freevar=False, dotprodsimp=None):
 
         # check for existence of solutions
         # rank of aug Matrix should be equal to rank of coefficient matrix
-        if not v[rank:, :].is_zero_matrix:
+        if not v[rank:, :].is_zero:
             raise ValueError("Linear system has no solution")
 
         # Get index of free symbols (free parameters)
@@ -3256,7 +3259,7 @@ def _eval_pinv_full_rank(self):
         This routine can apply for both cases by checking the shape
         and have small decision.
         """
-        if self.is_zero_matrix:
+        if self.is_zero:
             return self.H
 
         if self.rows >= self.cols:
@@ -3271,7 +3274,7 @@ def _eval_pinv_rank_decomposition(self):
         rank matrices, and each matrix can take pseudoinverse
         individually.
         """
-        if self.is_zero_matrix:
+        if self.is_zero:
             return self.H
 
         B, C = self.rank_decomposition()
@@ -3287,7 +3290,7 @@ def _eval_pinv_diagonalization(self):
         This routine can sometimes fail if SymPy's eigenvalue
         computation is not reliable.
         """
-        if self.is_zero_matrix:
+        if self.is_zero:
             return self.H
 
         A = self
@@ -3361,7 +3364,7 @@ def pinv(self, method='RD'):
 
         """
         # Trivial case: pseudoinverse of all-zero matrix is its transpose.
-        if self.is_zero_matrix:
+        if self.is_zero:
             return self.H
 
         if method == 'RD':
diff --git a/sympy/matrices/sparse.py b/sympy/matrices/sparse.py
index b99ac0c278..ee856a4047 100644
--- a/sympy/matrices/sparse.py
+++ b/sympy/matrices/sparse.py
@@ -1431,5 +1431,3 @@ def zip_row_op(self, i, k, f):
 
         """
         self.row_op(i, lambda v, j: f(v, self[k, j]))
-
-    is_zero = False
diff --git a/sympy/matrices/subspaces.py b/sympy/matrices/subspaces.py
index e78cac9d94..204d107f9c 100644
--- a/sympy/matrices/subspaces.py
+++ b/sympy/matrices/subspaces.py
@@ -202,7 +202,7 @@ def perp_to_subspace(vec, basis):
     ret  = []
     vecs = list(vecs) # make sure we start with a non-zero vector
 
-    while len(vecs) > 0 and vecs[0].is_zero_matrix:
+    while len(vecs) > 0 and vecs[0].is_zero:
         if rankcheck is False:
             del vecs[0]
         else:
@@ -211,7 +211,7 @@ def perp_to_subspace(vec, basis):
     for vec in vecs:
         perp = perp_to_subspace(vec, ret)
 
-        if not perp.is_zero_matrix:
+        if not perp.is_zero:
             ret.append(cls(perp))
         elif rankcheck is True:
             raise ValueError("GramSchmidt: vector set not linearly independent")
diff --git a/sympy/polys/multivariate_resultants.py b/sympy/polys/multivariate_resultants.py
index 24755aec45..c5ea3f4f65 100644
--- a/sympy/polys/multivariate_resultants.py
+++ b/sympy/polys/multivariate_resultants.py
@@ -194,7 +194,7 @@ def KSY_precondition(self, matrix):
         the last column. For the precondition to hold the last non-zero
         row of the rref matrix should be of the form [0, 0, ..., 1].
         """
-        if matrix.is_zero_matrix:
+        if matrix.is_zero:
             return False
 
         m, n = matrix.shape
@@ -213,10 +213,8 @@ def KSY_precondition(self, matrix):
 
     def delete_zero_rows_and_columns(self, matrix):
         """Remove the zero rows and columns of the matrix."""
-        rows = [
-            i for i in range(matrix.rows) if not matrix.row(i).is_zero_matrix]
-        cols = [
-            j for j in range(matrix.cols) if not matrix.col(j).is_zero_matrix]
+        rows = [i for i in range(matrix.rows) if not matrix.row(i).is_zero]
+        cols = [j for j in range(matrix.cols) if not matrix.col(j).is_zero]
 
         return matrix[rows, cols]
 
diff --git a/sympy/polys/polytools.py b/sympy/polys/polytools.py
index af1db9115e..1f15d8d98c 100644
--- a/sympy/polys/polytools.py
+++ b/sympy/polys/polytools.py
@@ -6593,7 +6593,7 @@ def cancel(f, *gens, **args):
     Examples
     ========
 
-    >>> from sympy import cancel, sqrt, Symbol, together
+    >>> from sympy import cancel, sqrt, Symbol
     >>> from sympy.abc import x
     >>> A = Symbol('A', commutative=False)
 
@@ -6601,14 +6601,6 @@ def cancel(f, *gens, **args):
     (2*x + 2)/(x - 1)
     >>> cancel((sqrt(3) + sqrt(15)*A)/(sqrt(2) + sqrt(10)*A))
     sqrt(6)/2
-
-    Note: due to automatic distribution of Rationals, a sum divided by an integer
-    will appear as a sum. To recover a rational form use `together` on the result:
-
-    >>> cancel(x/2 + 1)
-    x/2 + 1
-    >>> together(_)
-    (x + 2)/2
     """
     from sympy.core.exprtools import factor_terms
     from sympy.functions.elementary.piecewise import Piecewise


Test patch:
diff --git a/sympy/calculus/tests/test_util.py b/sympy/calculus/tests/test_util.py
index 5035cceb4e..a3d34a6169 100644
--- a/sympy/calculus/tests/test_util.py
+++ b/sympy/calculus/tests/test_util.py
@@ -452,14 +452,14 @@ def test_AccumBounds_pow():
     assert AccumBounds(-1, 2)**oo == AccumBounds(-oo, oo)
     assert AccumBounds(-2, S.Half)**oo == AccumBounds(-oo, oo)
 
-    assert AccumBounds(1, 2)**x == Pow(AccumBounds(1, 2), x)
+    assert AccumBounds(1, 2)**x == Pow(AccumBounds(1, 2), x, evaluate=False)
 
     assert AccumBounds(2, 3)**(-oo) is S.Zero
     assert AccumBounds(0, 2)**(-oo) == AccumBounds(0, oo)
     assert AccumBounds(-1, 2)**(-oo) == AccumBounds(-oo, oo)
 
     assert (tan(x)**sin(2*x)).subs(x, AccumBounds(0, pi/2)) == \
-        Pow(AccumBounds(-oo, oo), AccumBounds(0, 1))
+        Pow(AccumBounds(-oo, oo), AccumBounds(0, 1), evaluate=False)
 
 
 def test_comparison_AccumBounds():
diff --git a/sympy/combinatorics/tests/test_perm_groups.py b/sympy/combinatorics/tests/test_perm_groups.py
index ad6eaa941f..8deda10723 100644
--- a/sympy/combinatorics/tests/test_perm_groups.py
+++ b/sympy/combinatorics/tests/test_perm_groups.py
@@ -1097,22 +1097,3 @@ def test_is_symmetric():
     a = Permutation(0, 1, 2, 3)
     b = Permutation(0, 3)(1, 2)
     assert PermutationGroup(a, b).is_symmetric == False
-
-def test_conjugacy_class():
-    S = SymmetricGroup(4)
-    x = Permutation(1, 2, 3)
-    C = set([Permutation(0, 1, 2, size = 4), Permutation(0, 1, 3),
-             Permutation(0, 2, 1, size = 4), Permutation(0, 2, 3),
-             Permutation(0, 3, 1), Permutation(0, 3, 2),
-             Permutation(1, 2, 3), Permutation(1, 3, 2)])
-    assert S.conjugacy_class(x) == C
-
-def test_conjugacy_classes():
-    S = SymmetricGroup(3)
-    expected = [set([Permutation(size = 3)]),
-         set([Permutation(0, 1, size = 3), Permutation(0, 2), Permutation(1, 2)]),
-         set([Permutation(0, 1, 2), Permutation(0, 2, 1)])]
-    computed = S.conjugacy_classes()
-
-    assert len(expected) == len(computed)
-    assert all(e in computed for e in expected)
diff --git a/sympy/core/tests/test_compatibility.py b/sympy/core/tests/test_compatibility.py
index af3bddba10..4edb5a3154 100644
--- a/sympy/core/tests/test_compatibility.py
+++ b/sympy/core/tests/test_compatibility.py
@@ -75,3 +75,10 @@ def test_ordered():
     assert list(ordered(l, warn=True)) == [[1], [1], [2]]
     raises(ValueError, lambda: list(ordered(['a', 'ab'], keys=[lambda x: x[0]],
         default=False, warn=True)))
+
+
+def test_round():
+    from sympy.core.compatibility import round
+    # XXX delete this test when PY2 is dropped
+    assert round(S(12.3)).is_Integer
+    assert round(S(12.3), 0).is_Float
diff --git a/sympy/functions/combinatorial/tests/test_comb_factorials.py b/sympy/functions/combinatorial/tests/test_comb_factorials.py
index 54f3e89a2b..09e62d05dd 100644
--- a/sympy/functions/combinatorial/tests/test_comb_factorials.py
+++ b/sympy/functions/combinatorial/tests/test_comb_factorials.py
@@ -147,9 +147,7 @@ def test_ff_eval_apply():
     for i in range(100):
         x = -500 + 500 * random.random()
         k = -500 + 500 * random.random()
-        a = mpmath_ff(x, k)
-        b = ff(x, k)
-        assert (abs(a - b) < abs(a) * 10**(-15))
+        assert (abs(mpmath_ff(x, k) - ff(x, k)) < 10**(-15))
 
 
 def test_rf_ff_eval_hiprec():
diff --git a/sympy/functions/elementary/tests/test_piecewise.py b/sympy/functions/elementary/tests/test_piecewise.py
index fd609c9f71..17b0bacf32 100644
--- a/sympy/functions/elementary/tests/test_piecewise.py
+++ b/sympy/functions/elementary/tests/test_piecewise.py
@@ -2,7 +2,7 @@
     adjoint, And, Basic, conjugate, diff, expand, Eq, Function, I, ITE,
     Integral, integrate, Interval, KroneckerDelta, lambdify, log, Max, Min,
     oo, Or, pi, Piecewise, piecewise_fold, Rational, solve, symbols, transpose,
-    cos, sin, exp, Abs, Ne, Not, Symbol, S, sqrt, Sum, Tuple, zoo, Float,
+    cos, sin, exp, Abs, Ne, Not, Symbol, S, sqrt, Sum, Tuple, zoo,
     DiracDelta, Heaviside, Add, Mul, factorial, Ge, Contains)
 from sympy.core.expr import unchanged
 from sympy.functions.elementary.piecewise import Undefined, ExprCondPair
@@ -1345,9 +1345,3 @@ def test_identical_conds_issue():
     # Result is quite big, so not really important here (and should ideally be
     # simpler). Should not give an exception though.
     density(u1 + u2)
-
-
-def test_issue_7370():
-    f = Piecewise((1, x <= 2400))
-    v = integrate(f, (x, 0, Float("252.4", 30)))
-    assert str(v) == '252.400000000000000000000000000'
diff --git a/sympy/matrices/tests/test_commonmatrix.py b/sympy/matrices/tests/test_commonmatrix.py
index d29af83226..5ae0cfaa39 100644
--- a/sympy/matrices/tests/test_commonmatrix.py
+++ b/sympy/matrices/tests/test_commonmatrix.py
@@ -440,14 +440,14 @@ def test_is_hessenberg():
 
 
 def test_is_zero():
-    assert PropertiesOnlyMatrix(0, 0, []).is_zero_matrix
-    assert PropertiesOnlyMatrix([[0, 0], [0, 0]]).is_zero_matrix
-    assert PropertiesOnlyMatrix(zeros(3, 4)).is_zero_matrix
-    assert not PropertiesOnlyMatrix(eye(3)).is_zero_matrix
-    assert PropertiesOnlyMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
-    assert PropertiesOnlyMatrix([[x, 1], [0, 0]]).is_zero_matrix == False
+    assert PropertiesOnlyMatrix(0, 0, []).is_zero
+    assert PropertiesOnlyMatrix([[0, 0], [0, 0]]).is_zero
+    assert PropertiesOnlyMatrix(zeros(3, 4)).is_zero
+    assert not PropertiesOnlyMatrix(eye(3)).is_zero
+    assert PropertiesOnlyMatrix([[x, 0], [0, 0]]).is_zero == None
+    assert PropertiesOnlyMatrix([[x, 1], [0, 0]]).is_zero == False
     a = Symbol('a', nonzero=True)
-    assert PropertiesOnlyMatrix([[a, 0], [0, 0]]).is_zero_matrix == False
+    assert PropertiesOnlyMatrix([[a, 0], [0, 0]]).is_zero == False
 
 
 def test_values():
diff --git a/sympy/matrices/tests/test_matrices.py b/sympy/matrices/tests/test_matrices.py
index cce489d755..a0800e5cef 100644
--- a/sympy/matrices/tests/test_matrices.py
+++ b/sympy/matrices/tests/test_matrices.py
@@ -3083,17 +3083,17 @@ def test_zeros_eye():
 
 
 def test_is_zero():
-    assert Matrix().is_zero_matrix
-    assert Matrix([[0, 0], [0, 0]]).is_zero_matrix
-    assert zeros(3, 4).is_zero_matrix
-    assert not eye(3).is_zero_matrix
-    assert Matrix([[x, 0], [0, 0]]).is_zero_matrix == None
-    assert SparseMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
-    assert ImmutableMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
-    assert ImmutableSparseMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
-    assert Matrix([[x, 1], [0, 0]]).is_zero_matrix == False
+    assert Matrix().is_zero
+    assert Matrix([[0, 0], [0, 0]]).is_zero
+    assert zeros(3, 4).is_zero
+    assert not eye(3).is_zero
+    assert Matrix([[x, 0], [0, 0]]).is_zero == None
+    assert SparseMatrix([[x, 0], [0, 0]]).is_zero == None
+    assert ImmutableMatrix([[x, 0], [0, 0]]).is_zero == None
+    assert ImmutableSparseMatrix([[x, 0], [0, 0]]).is_zero == None
+    assert Matrix([[x, 1], [0, 0]]).is_zero == False
     a = Symbol('a', nonzero=True)
-    assert Matrix([[a, 0], [0, 0]]).is_zero_matrix == False
+    assert Matrix([[a, 0], [0, 0]]).is_zero == False
 
 
 def test_rotation_matrices():
diff --git a/sympy/series/tests/test_limits.py b/sympy/series/tests/test_limits.py
index a001378e8a..93eb22b3d8 100644
--- a/sympy/series/tests/test_limits.py
+++ b/sympy/series/tests/test_limits.py
@@ -608,6 +608,3 @@ def test_issue_17671():
 
 def test_issue_18306():
     assert limit(sin(sqrt(x))/sqrt(sin(x)), x, 0, '+') == 1
-
-def test_issue_18442():
-    assert limit(tan(x)**(2**(sqrt(pi))), x, oo, dir='-') == AccumBounds(-oo, oo)
diff --git a/sympy/series/tests/test_series.py b/sympy/series/tests/test_series.py
index 00e88618e6..c7f035f087 100644
--- a/sympy/series/tests/test_series.py
+++ b/sympy/series/tests/test_series.py
@@ -218,3 +218,6 @@ def test_issue_7259():
     assert series(LambertW(x), x) == x - x**2 + 3*x**3/2 - 8*x**4/3 + 125*x**5/24 + O(x**6)
     assert series(LambertW(x**2), x, n=8) == x**2 - x**4 + 3*x**6/2 + O(x**8)
     assert series(LambertW(sin(x)), x, n=4) == x - x**2 + 4*x**3/3 + O(x**4)
+
+def test_issue_11884():
+    assert cos(x).series(x, 1, n=1) == cos(1) + O(x - 1, (x, 1))