Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Mul.is_imaginary for infinite values #18192

Merged
merged 4 commits into from Jan 21, 2020

Conversation

namannimmo10
Copy link
Member

@namannimmo10 namannimmo10 commented Dec 31, 2019

References to other Issues or PRs

Fixes #17556

Brief description of what is fixed or changed

Other comments

Release Notes

  • assumptions
    • Updated Mul.is_imaginary to support infinite values.

@sympy-bot
Copy link

sympy-bot commented Dec 31, 2019

Hi, I am the SymPy bot (v149). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->
Fixes #17556

#### Brief description of what is fixed or changed


#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* assumptions
    *  Updated `Mul.is_imaginary` to support infinite values.
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@namannimmo10
Copy link
Member Author

@oscarbenjamin could you please look into this?

@namannimmo10
Copy link
Member Author

from travis' log:

File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/sympy-1.6.dev0-py3.8.egg/sympy/functions/special/tests/test_bessel.py", line 312, in test_bessel_eval
assert f(m, I*S.Infinity) is S.Zero
AssertionError

@oscarbenjamin
Copy link
Contributor

If you find where that failed test is you can get the code from there to see what has changed. Presumably the bessel function now evaluates differently for I*oo so the logic there might need to be fixed.

@namannimmo10
Copy link
Member Author

Okay, I'll look into it. Happy new year btw!

@Sc0rpi0n101
Copy link
Member

The release notes should be something like
Updated Mul.is_imaginary to support infinite values
or
Mul.is_imaginary now supports infinite values

There is no need to mention the changes to tests, they do not affect the users.

@namannimmo10
Copy link
Member Author

@Sc0rpi0n101 Thanks for the advice.

There is no need to mention the changes to tests, they do not affect the users.

I'll consider that for the future PRs.

@vikrantmalik051
Copy link
Contributor

This should fix the failing tests.

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():

@namannimmo10
Copy link
Member Author

Thank you, @V1krant. :)

@namannimmo10
Copy link
Member Author

@oscarbenjamin @czgdp1807 This diff indeed fixes the failing test.
But I'm getting ImportError on travis. What could be the reason behind that?
Travis' log:

File "/home/travis/.venv-no-setuptools/lib/python3.5/site-packages/pip/_internal/operations/prepare.py", line 16, in
from pip._internal.distributions import (
File "/home/travis/.venv-no-setuptools/lib/python3.5/site-packages/pip/_internal/distributions/init.py", line 1, in
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution'

There's no such failure on running the tests locally.

@oscarbenjamin
Copy link
Contributor

That's a bug in pip

@namannimmo10
Copy link
Member Author

How can I fix that?

@codecov
Copy link

codecov bot commented Jan 21, 2020

Codecov Report

Merging #18192 into master will increase coverage by 0.009%.
The diff coverage is 83.255%.

@@             Coverage Diff              @@
##            master   #18192       +/-   ##
============================================
+ Coverage   75.311%   75.32%   +0.009%     
============================================
  Files          635      637        +2     
  Lines       167071   167069        -2     
  Branches     39422    39416        -6     
============================================
+ Hits        125823   125838       +15     
+ Misses       35711    35689       -22     
- Partials      5537     5542        +5

@oscarbenjamin
Copy link
Contributor

Looks good. Thanks all.

@oscarbenjamin oscarbenjamin merged commit c0a1666 into sympy:master Jan 21, 2020
@namannimmo10
Copy link
Member Author

Thanks all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mul.is_imaginary fails for infinite values
6 participants