Repository: sympy/sympy

Issue:
Q.prime returns False when it should return None
The documentation for `ask` gives the following example:
```py
>>> ask(Q.prime(x*y), Q.integer(x) &  Q.integer(y))
False
```
which is wrong if one integer is a unit.

Discussion:

Patch:
diff --git a/sympy/assumptions/ask.py b/sympy/assumptions/ask.py
index 38644893d3..b79995b85c 100644
--- a/sympy/assumptions/ask.py
+++ b/sympy/assumptions/ask.py
@@ -1232,7 +1232,7 @@ def ask(proposition, assumptions=True, context=global_assumptions):
     False
     >>> ask(Q.even(x*y), Q.even(x) & Q.integer(y))
     True
-    >>> ask(Q.prime(x*y), Q.integer(x) &  Q.integer(y))
+    >>> ask(Q.prime(4*x), Q.integer(x))
     False
 
     **Remarks**
diff --git a/sympy/assumptions/handlers/ntheory.py b/sympy/assumptions/handlers/ntheory.py
index 83632a4a4c..a744e407f0 100644
--- a/sympy/assumptions/handlers/ntheory.py
+++ b/sympy/assumptions/handlers/ntheory.py
@@ -45,13 +45,11 @@ def Mul(expr, assumptions):
         if expr.is_number:
             return AskPrimeHandler._number(expr, assumptions)
         for arg in expr.args:
-            if ask(Q.integer(arg), assumptions):
-                pass
-            else:
-                break
-        else:
-            # a product of integers can't be a prime
-            return False
+            if not ask(Q.integer(arg), assumptions):
+                return None
+        for arg in expr.args:
+            if arg.is_number and arg.is_composite:
+                return False
 
     @staticmethod
     def Pow(expr, assumptions):
diff --git a/sympy/plotting/plot.py b/sympy/plotting/plot.py
index 664602d6ba..b1ead153ef 100644
--- a/sympy/plotting/plot.py
+++ b/sympy/plotting/plot.py
@@ -922,9 +922,9 @@ def process_series(self):
                 self.ax.set_zlim((min(z), max(z)))
             elif s.is_3Dsurface:
                 x, y, z = s.get_meshes()
-                collection = self.ax.plot_surface(x, y, z,
-                    cmap=getattr(self.cm, 'viridis', self.cm.jet),
-                    rstride=1, cstride=1, linewidth=0.1)
+                collection = self.ax.plot_surface(x, y, z, cmap=self.cm.jet,
+                                                  rstride=1, cstride=1,
+                                                  linewidth=0.1)
             elif s.is_implicit:
                 #Smart bounds have to be set to False for implicit plots.
                 self.ax.spines['left'].set_smart_bounds(False)


Test patch:
diff --git a/sympy/assumptions/tests/test_query.py b/sympy/assumptions/tests/test_query.py
index 629ebadddd..9bdd799853 100644
--- a/sympy/assumptions/tests/test_query.py
+++ b/sympy/assumptions/tests/test_query.py
@@ -1705,10 +1705,12 @@ def test_prime():
     assert ask(Q.prime(x), Q.integer(x)) is None
     assert ask(Q.prime(x), ~Q.integer(x)) is False
 
-    assert ask(Q.prime(2*x), Q.integer(x)) is False
+    assert ask(Q.prime(2*x), Q.integer(x)) is None
     assert ask(Q.prime(x*y)) is None
     assert ask(Q.prime(x*y), Q.prime(x)) is None
-    assert ask(Q.prime(x*y), Q.integer(x) & Q.integer(y)) is False
+    assert ask(Q.prime(x*y), Q.integer(x) & Q.integer(y)) is None
+    assert ask(Q.prime(4*x), Q.integer(x)) is False
+    assert ask(Q.prime(4*x)) is None
 
     assert ask(Q.prime(x**2), Q.integer(x)) is False
     assert ask(Q.prime(x**2), Q.prime(x)) is False