Repository: sympy/sympy

Issue:
solveset(-oo < x) & solveset(oo > x) returns EmptySet()
```python
In [8]: x = Symbol('x', real=True)

In [9]: solveset(-oo < x)
Out[9]: EmptySet()

In [10]: solveset(oo > x)
Out[10]: EmptySet()
```

Though reversing the relational expression works.

Discussion:

Patch:
diff --git a/.gitignore b/.gitignore
index 0f8a7d6857..c8cf3a3d61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,7 +55,6 @@ doc/sphinx/
 
 # pdf files generated from svg files (cd doc; make latex)
 doc/src/modules/physics/mechanics/*.pdf
-doc/src/modules/physics/vector/*.pdf
 
 # Mac OS X Junk
 .DS_Store
@@ -68,4 +67,3 @@ sample.tex
 
 # IPython Notebook Checkpoints
 .ipynb_checkpoints/
-
diff --git a/.travis.yml b/.travis.yml
index 287d7db54f..f6fd26b80e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -117,14 +117,7 @@ before_install:
       sudo apt-get install sagemath-upstream-binary;
     fi
 install:
-#The install cycle below is to test installation on systems without setuptools.
-  - if [[ "${TEST_AUTOWRAP}" == "true" ]]; then
-      pip uninstall -y setuptools;
-      python setup.py install;
-      pip uninstall -y sympy;
-      pip install setuptools;
-      python setup.py install;
-    elif [[ "${TEST_SAGE}" != "true" ]]; then
+  - if [[ "${TEST_SAGE}" != "true" ]]; then
       python setup.py install;
     fi
 script:
diff --git a/README.rst b/README.rst
index b30fa5217d..cf0a9c420c 100644
--- a/README.rst
+++ b/README.rst
@@ -38,7 +38,7 @@ To get the git version do
 
     $ git clone git://github.com/sympy/sympy.git
 
-For other options (tarballs, debs, etc.), see
+For other options (tarballs, debs, etc.), see See
 http://docs.sympy.org/dev/install.html.
 
 Documentation and usage
diff --git a/setup.py b/setup.py
index 26ae363efb..762f57aa10 100755
--- a/setup.py
+++ b/setup.py
@@ -34,7 +34,7 @@
 try:
     from setuptools import setup, Command
 except ImportError:
-    from distutils.core import setup, Command
+    from distutils import setup, Command
 
     # handle mpmath deps in the hard way:
     from distutils.version import LooseVersion
@@ -50,7 +50,6 @@
 import subprocess
 import os
 import shutil
-import glob
 
 PY3 = sys.version_info[0] > 2
 
@@ -191,11 +190,6 @@ def run(self):
             elif os.path.isdir(f):
                 shutil.rmtree(f)
 
-        for name in glob.glob(os.path.join(dir_setup, "doc", "src", "modules", \
-                                           "physics", "vector", "*.pdf")):
-            if os.path.isfile(name):
-                os.remove(name)
-
         os.chdir(curr_dir)
 
 
diff --git a/sympy/physics/mechanics/kane.py b/sympy/physics/mechanics/kane.py
index 842bf548a9..4a6a050454 100644
--- a/sympy/physics/mechanics/kane.py
+++ b/sympy/physics/mechanics/kane.py
@@ -132,9 +132,9 @@ def __init__(self, frame, q_ind, u_ind, kd_eqs=None, q_dependent=None,
 
         self._initialize_vectors(q_ind, q_dependent, u_ind, u_dependent,
                 u_auxiliary)
-        self._initialize_kindiffeq_matrices(kd_eqs)
         self._initialize_constraint_matrices(configuration_constraints,
                 velocity_constraints, acceleration_constraints)
+        self._initialize_kindiffeq_matrices(kd_eqs)
 
     def _initialize_vectors(self, q_ind, q_dep, u_ind, u_dep, u_aux):
         """Initialize the coordinate and speed vectors."""
@@ -193,14 +193,6 @@ def _initialize_constraint_matrices(self, config, vel, acc):
             u_zero = dict((i, 0) for i in self.u)
             udot_zero = dict((i, 0) for i in self._udot)
 
-            # When calling kanes_equations, another class instance will be
-            # created if auxiliary u's are present. In this case, the
-            # computation of kinetic differential equation matrices will be
-            # skipped as this was computed during the original KanesMethod
-            # object, and the qd_u_map will not be available.
-            if self._qdot_u_map is not None:
-                vel = vel.subs(self._qdot_u_map)
-
             self._f_nh = vel.subs(u_zero)
             self._k_nh = (vel - self._f_nh).jacobian(self.u)
             # If no acceleration constraints given, calculate them.
@@ -209,8 +201,6 @@ def _initialize_constraint_matrices(self, config, vel, acc):
                                self._f_nh.diff(dynamicsymbols._t))
                 self._k_dnh = self._k_nh
             else:
-                if self._qdot_u_map is not None:
-                    acc = acc.subs(self._qdot_u_map)
                 self._f_dnh = acc.subs(udot_zero)
                 self._k_dnh = (acc - self._f_dnh).jacobian(self._udot)
 
diff --git a/sympy/solvers/inequalities.py b/sympy/solvers/inequalities.py
index 58274f056b..4982a72097 100644
--- a/sympy/solvers/inequalities.py
+++ b/sympy/solvers/inequalities.py
@@ -410,6 +410,7 @@ def solve_univariate_inequality(expr, gen, relational=True):
             singularities.extend(solve(d, gen))
 
     include_x = expr.func(0, 0)
+
     def valid(x):
         v = e.subs(gen, x)
         r = expr.func(v, 0)
@@ -432,10 +433,10 @@ def valid(x):
     for x in reals:
         end = x
 
-        if ((end is S.NegativeInfinity and expr.rel_op in ['>', '>=']) or
-           (end is S.Infinity and expr.rel_op in ['<', '<='])):
-            sol_sets.append(Interval(start, S.Infinity, True, True))
-            break
+        if end in [S.NegativeInfinity, S.Infinity]:
+            if valid(S(0)):
+                sol_sets.append(Interval(start, S.Infinity, True, True))
+                break
 
         if valid((start + end)/2 if start != S.NegativeInfinity else end - 1):
             sol_sets.append(Interval(start, end, True, True))


Test patch:
diff --git a/sympy/logic/tests/test_boolalg.py b/sympy/logic/tests/test_boolalg.py
index bd8ed6fa45..90be72dc9c 100644
--- a/sympy/logic/tests/test_boolalg.py
+++ b/sympy/logic/tests/test_boolalg.py
@@ -684,3 +684,9 @@ def test_issue_8777():
     assert And(x >= 1, x < oo).as_set() == Interval(1, oo)
     assert (x < oo).as_set() == Interval(-oo, oo)
     assert (x > -oo).as_set() == Interval(-oo, oo)
+
+
+def test_issue_8975():
+    x = symbols('x')
+    assert Or(And(-oo < x, x <= -2), And(2 <= x, x < oo)).as_set() == \
+        Interval(-oo, -2) + Interval(2, oo)
diff --git a/sympy/physics/mechanics/tests/test_kane2.py b/sympy/physics/mechanics/tests/test_kane2.py
index e2cec1737c..fb0ec6f142 100644
--- a/sympy/physics/mechanics/tests/test_kane2.py
+++ b/sympy/physics/mechanics/tests/test_kane2.py
@@ -1,5 +1,5 @@
 from sympy.core.compatibility import range
-from sympy import cos, Matrix, simplify, sin, solve, tan, pi
+from sympy import cos, Matrix, simplify, sin, solve
 from sympy import symbols, trigsimp, zeros
 from sympy.physics.mechanics import (cross, dot, dynamicsymbols, KanesMethod,
                                      inertia, inertia_of_point_mass,
@@ -373,83 +373,3 @@ def test_sub_qdot():
     fr, fr_star = km.kanes_equations(forces, bodies)
     assert (fr.expand() == fr_expected.expand())
     assert (trigsimp(fr_star).expand() == fr_star_expected.expand())
-
-def test_sub_qdot2():
-    # This test solves exercises 8.3 from Kane 1985 and defines
-    # all velocities in terms of q, qdot. We check that the generalized active
-    # forces are correctly computed if u terms are only defined in the
-    # kinematic differential equations.
-    #
-    # This functionality was added in PR 8948. Without qdot/u substitution, the
-    # KanesMethod constructor will fail during the constraint initialization as
-    # the B matrix will be poorly formed and inversion of the dependent part
-    # will fail.
-
-    g, m, Px, Py, Pz, R, t = symbols('g m Px Py Pz R t')
-    q = dynamicsymbols('q:5')
-    qd = dynamicsymbols('q:5', level=1)
-    u = dynamicsymbols('u:5')
-
-    ## Define inertial, intermediate, and rigid body reference frames
-    A = ReferenceFrame('A')
-    B_prime = A.orientnew('B_prime', 'Axis', [q[0], A.z])
-    B = B_prime.orientnew('B', 'Axis', [pi/2 - q[1], B_prime.x])
-    C = B.orientnew('C', 'Axis', [q[2], B.z])
-
-    ## Define points of interest and their velocities
-    pO = Point('O')
-    pO.set_vel(A, 0)
-
-    # R is the point in plane H that comes into contact with disk C.
-    pR = pO.locatenew('R', q[3]*A.x + q[4]*A.y)
-    pR.set_vel(A, pR.pos_from(pO).diff(t, A))
-    pR.set_vel(B, 0)
-
-    # C^ is the point in disk C that comes into contact with plane H.
-    pC_hat = pR.locatenew('C^', 0)
-    pC_hat.set_vel(C, 0)
-
-    # C* is the point at the center of disk C.
-    pCs = pC_hat.locatenew('C*', R*B.y)
-    pCs.set_vel(C, 0)
-    pCs.set_vel(B, 0)
-
-    # calculate velocites of points C* and C^ in frame A
-    pCs.v2pt_theory(pR, A, B) # points C* and R are fixed in frame B
-    pC_hat.v2pt_theory(pCs, A, C) # points C* and C^ are fixed in frame C
-
-    ## Define forces on each point of the system
-    R_C_hat = Px*A.x + Py*A.y + Pz*A.z
-    R_Cs = -m*g*A.z
-    forces = [(pC_hat, R_C_hat), (pCs, R_Cs)]
-
-    ## Define kinematic differential equations
-    # let ui = omega_C_A & bi (i = 1, 2, 3)
-    # u4 = qd4, u5 = qd5
-    u_expr = [C.ang_vel_in(A) & uv for uv in B]
-    u_expr += qd[3:]
-    kde = [ui - e for ui, e in zip(u, u_expr)]
-    km1 = KanesMethod(A, q, u, kde)
-    fr1, _ = km1.kanes_equations(forces, [])
-
-    ## Calculate generalized active forces if we impose the condition that the
-    # disk C is rolling without slipping
-    u_indep = u[:3]
-    u_dep = list(set(u) - set(u_indep))
-    vc = [pC_hat.vel(A) & uv for uv in [A.x, A.y]]
-    km2 = KanesMethod(A, q, u_indep, kde,
-                      u_dependent=u_dep, velocity_constraints=vc)
-    fr2, _ = km2.kanes_equations(forces, [])
-
-    fr1_expected = Matrix([
-        -R*g*m*sin(q[1]),
-        -R*(Px*cos(q[0]) + Py*sin(q[0]))*tan(q[1]),
-        R*(Px*cos(q[0]) + Py*sin(q[0])),
-        Px,
-        Py])
-    fr2_expected = Matrix([
-        -R*g*m*sin(q[1]),
-        0,
-        0])
-    assert (trigsimp(fr1.expand()) == trigsimp(fr1_expected.expand()))
-    assert (trigsimp(fr2.expand()) == trigsimp(fr2_expected.expand()))
diff --git a/sympy/solvers/tests/test_inequalities.py b/sympy/solvers/tests/test_inequalities.py
index e6f5622167..c5f8ff4287 100644
--- a/sympy/solvers/tests/test_inequalities.py
+++ b/sympy/solvers/tests/test_inequalities.py
@@ -297,3 +297,8 @@ def test_issue_8545():
     assert reduce_abs_inequality(eq, '<', x) == ans
     eq = 1 - x - sqrt((1 - x)**2)
     assert reduce_inequalities(eq < 0) == ans
+
+
+def test_issue_8974():
+    assert isolve(-oo < x, x) == And(-oo < x, x < oo)
+    assert isolve(oo > x, x) == And(-oo < x, x < oo)