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

solveset with piecewise: issue 19718 #19986

Merged
merged 2 commits into from Aug 31, 2020

Conversation

maurogaravello
Copy link
Contributor

@maurogaravello maurogaravello commented Aug 19, 2020

References to other Issues or PRs

Fixes #19718

Brief description of what is fixed or changed

Solveset with inequality and Piecewise does not work properly.
Indeed it is _solveset which returns a wrong result when an argument is a BooleanTrue.
Now, when the argument is a BooleanTrue, it returns the domain.

A test is added.

Other comments

Release Notes

  • solvers
    • Handling of inequalities involving Piecewise is improved in solveset.

@sympy-bot
Copy link

sympy-bot commented Aug 19, 2020

Hi, I am the SymPy bot (v160). 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:

  • solvers

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

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://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

Fixes #19718 


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

`Solveset` with `inequality` and `Piecewise` does not work properly.
Indeed it is `_solveset` which returns a wrong result when an argument is a `BooleanTrue`.
Now, when the argument is a `BooleanTrue`, it returns the domain.

A test is added.

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

- solvers
  - Handling of inequalities involving Piecewise is improved in solveset.

<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented Aug 19, 2020

Codecov Report

Merging #19986 into master will increase coverage by 0.057%.
The diff coverage is 100.000%.

@@              Coverage Diff              @@
##            master    #19986       +/-   ##
=============================================
+ Coverage   75.825%   75.882%   +0.057%     
=============================================
  Files          669       669               
  Lines       173475    173566       +91     
  Branches     40911     40970       +59     
=============================================
+ Hits        131539    131707      +168     
+ Misses       36210     36130       -80     
- Partials      5726      5729        +3     

from sympy.logic.boolalg import BooleanTrue

if isinstance(f, BooleanTrue):
return domain
Copy link
Member

@czgdp1807 czgdp1807 Aug 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line isn't covered by the tests according to this report. Can you please add some tests covering this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like this?

    f = BooleanTrue()
    assert solveset(f, x, domain=Interval(-3, 10)) == Interval(-3, 10)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This should work.

@czgdp1807
Copy link
Member

@smichr Is this good to go?

@oscarbenjamin
Copy link
Contributor

Looks good. Thanks!

@oscarbenjamin oscarbenjamin merged commit 0c6b331 into sympy:master Aug 31, 2020
@maurogaravello maurogaravello deleted the issue-19718 branch September 1, 2020 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

solveset and Piecewise give wrong result
4 participants