Repository: sympy/sympy

Issue:
Mul.is_imaginary fails for infinite values
After #16666 we have that imaginary implies finite. The `Mul._eval_is_imaginary` method needs to be updated to reflect this:
```julia
In [1]: z = sqrt(-oo)                                                                                                             

In [2]: z.is_imaginary                                                                                                            
Out[2]: True

In [3]: z.is_finite                                                                                                               
Out[3]: True

In [4]: z                                                                                                                         
Out[4]: ∞⋅ⅈ

In [5]: z._eval_is_imaginary()                                                                                                    
Out[5]: True

In [6]: z._eval_is_finite()                                                                                                       
Out[6]: False
```

Discussion:

Patch:
diff --git a/sympy/core/mul.py b/sympy/core/mul.py
index 42b1cd47b9..06b942bd7c 100644
--- a/sympy/core/mul.py
+++ b/sympy/core/mul.py
@@ -1318,7 +1318,9 @@ def _eval_is_imaginary(self):
         z = self.is_zero
         if z:
             return False
-        elif z is False:
+        if self.is_finite is False:
+            return False
+        elif z is False and self.is_finite is True:
             return self._eval_real_imag(False)
 
     def _eval_is_hermitian(self):
diff --git a/sympy/functions/special/bessel.py b/sympy/functions/special/bessel.py
index fd839e00b0..5a2395a0a3 100644
--- a/sympy/functions/special/bessel.py
+++ b/sympy/functions/special/bessel.py
@@ -350,9 +350,8 @@ def eval(cls, nu, z):
                 return S.ComplexInfinity
             elif nu.is_imaginary:
                 return S.NaN
-        if z.is_imaginary:
-            if im(z) is S.Infinity or im(z) is S.NegativeInfinity:
-                return S.Zero
+        if im(z) is S.Infinity or im(z) is S.NegativeInfinity:
+            return S.Zero
 
         if z.could_extract_minus_sign():
             return (z)**nu*(-z)**(-nu)*besseli(nu, -z)
@@ -449,9 +448,8 @@ def eval(cls, nu, z):
                 return S.ComplexInfinity
             elif re(nu).is_zero:
                 return S.NaN
-        if z.is_imaginary:
-            if im(z) is S.Infinity or im(z) is S.NegativeInfinity:
-                return S.Zero
+        if im(z) is S.Infinity or im(z) is S.NegativeInfinity:
+            return S.Zero
 
         if nu.is_integer:
             if nu.could_extract_minus_sign():


Test patch:
diff --git a/sympy/core/tests/test_assumptions.py b/sympy/core/tests/test_assumptions.py
index 7a539af02c..08bb2a16aa 100644
--- a/sympy/core/tests/test_assumptions.py
+++ b/sympy/core/tests/test_assumptions.py
@@ -1,4 +1,4 @@
-from sympy import I, sqrt, log, exp, sin, asin, factorial, Mod, pi
+from sympy import I, sqrt, log, exp, sin, asin, factorial, Mod, pi, oo
 from sympy.core import Symbol, S, Rational, Integer, Dummy, Wild, Pow
 from sympy.core.facts import InconsistentAssumptions
 from sympy import simplify
@@ -1179,3 +1179,8 @@ def test_issue_16579():
     c = Symbol('c', complex=True)
     assert c.is_finite is True
     raises(InconsistentAssumptions, lambda: Dummy(complex=True, finite=False))
+
+def test_issue_17556():
+    z = I*oo
+    assert z.is_imaginary is False
+    assert z.is_finite is False