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

Stats: Corrections to conditions of type Or #14578

Merged
merged 1 commit into from
Apr 3, 2018

Conversation

akash9712
Copy link
Contributor

Previously, the domain where conditions of type Or were valid was calculated
in a way that resulted in the condition being treated in the same way as
And. This PR is to fix this wrong result. Tests for the same have been
added.

Examples:
(Before Fix)

>>> E = Exponential('E', 1)
>>> P(Or(E < 0, E > 0))
0
>>> P(Or(E > 1, E > 2)) == P(And(E > 1, E > 2))
True

(After fix)

>>> E = Exponential('E', 1)
>>> P(Or(E < 0, E > 0))
1
>>> P(Or(E > 1, E > 2)) == P(E > 1)
True

References to other Issues or PRs

Brief description of what is fixed or changed

Other comments

Previously, domain where conditions of type `Or` were valid was calculated
in a way that resulted in the condition being treated in the same way as
`And`. This PR is to fix this wrong result. Tests for the same have been
added.

Examples:
(Before Fix)```
>>> E = Exponential('E', 1)
>>> P(Or(E < 0, E > 0))
0
>>> P(Or(E > 1, E > 2)) == P(And(E > 1, E > 2))
True
```
(After fix)```
>>> E = Exponential('E', 1)
>>> P(Or(E < 0, E > 0))
1
>>> P(Or(E > 1, E > 2)) == P(E > 1)
True
```
@@ -484,8 +484,8 @@ def reduce_rational_inequalities_wrap(condition, var):
if condition.is_Relational:
return _reduce_inequalities([[condition]], var, relational=False)
if condition.__class__ is Or:
Copy link
Member

Choose a reason for hiding this comment

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

I know this isn't code you wrote, but this should be isinstance(condition, Or).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. I have opened #14598 for this.

@asmeurer asmeurer merged commit b9f5973 into sympy:master Apr 3, 2018
@akash9712 akash9712 deleted the stats_where branch April 4, 2018 18:01
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.

2 participants