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

Fix for Mul.is_real #16357

Merged
merged 3 commits into from Mar 21, 2019
Merged

Fix for Mul.is_real #16357

merged 3 commits into from Mar 21, 2019

Conversation

ShubhamKJha
Copy link
Member

References to other Issues or PRs

Fixes #16313

Brief description of what is fixed or changed

Consider the following code:

>>> from sympy import symbols
>>> x = symbols('x', real=False)
>>> (-x).is_real
>>>

Apparently the negation of a non-real should be non-real but I still don't know what non-real numbers do sympy support and what symbols with real=False could imply.

Are there any non-real numbers when multiplied by -1 produces real numbers?

But by understanding the code in sympy.core.Mul.is_eval_real_imag(), I could infer that since complex = None would mean either complex=True or complex=False in both of these cases the present code was giving result False with real=False. So the desired result is also False.

Other comments

Release Notes

NO ENTRY

@sympy-bot
Copy link

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

  • No release notes entry will be added for this pull request.

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 #16313 

#### Brief description of what is fixed or changed
Consider the following code:
```py
>>> from sympy import symbols
>>> x = symbols('x', real=False)
>>> (-x).is_real
>>>
```
Apparently the negation of a non-real should be non-real but I still don't know what non-real numbers do sympy support and what symbols with `real=False` could imply.

`Are there any non-real numbers when multiplied by -1 produces real numbers?`

But by understanding the code in `sympy.core.Mul.is_eval_real_imag()`, I could infer that since `complex = None` would mean either `complex=True` or `complex=False` in both of these cases the present code was giving result `False` with `real=False`. So the desired result is also `False`.

#### 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 -->
NO ENTRY
<!-- END RELEASE NOTES -->

@jksuom
Copy link
Member

jksuom commented Mar 21, 2019

Can you add a unit test?

@ShubhamKJha
Copy link
Member Author

@jksuom I added tests.

@jksuom
Copy link
Member

jksuom commented Mar 21, 2019

Thanks, looks ok.

@jksuom jksuom merged commit e941ad6 into sympy:master Mar 21, 2019
@ShubhamKJha ShubhamKJha deleted the new_mul_fix branch March 22, 2019 00:36
@ShubhamKJha
Copy link
Member Author

Thanks @jksuom

@asmeurer
Copy link
Member

Please include release notes entries in the future.

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

Successfully merging this pull request may close these issues.

For non-real expressions isn't the is_positive property always False?
4 participants