You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changing the line 265 of mul.py in the following way: elif coeff.is_Number: # it could be zoo (original line) elif coeff.is_Number or isinstance(coeff, AccumBounds): # it could be zoo (modified)
the code
coeff *= o
if coeff is S.NaN:
# we know for sure the result will be nan
return [S.NaN], [], None
is executed also in the case coeff is AccumBounds(-1, 1) (or similar) and,
in case o is 0, then coeff becomes 0.
Other comments
A test is added.
Release Notes
core
fixed a bug about commutativity of Mul with AccumBounds
Changing the line 265 of mul.py in the following way:
elif coeff.is_Number: # it could be zoo (original line)
elif coeff.is_Number or isinstance(coeff, AccumBounds): # it could be zoo (modified)
the code
coeff *= o
if coeff is S.NaN:
# we know for sure the result will be nan
return [S.NaN], [], None
is executed also in the case coeff is AccumBounds(-1, 1) (or similar) and,
in case o is 0, then coeff becomes 0.
A test is added.
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 .-->
Fixes #13159
#### Brief description of what is fixed or changed
Changing the line 265 of `mul.py` in the following way:
`elif coeff.is_Number: # it could be zoo` (original line)
`elif coeff.is_Number or isinstance(coeff, AccumBounds): # it could be zoo` (modified)
the code
```
coeff *= o
if coeff is S.NaN:
# we know for sure the result will be nan
return [S.NaN], [], None
```
is executed also in the case `coeff` is `AccumBounds(-1, 1)` (or similar) and,
in case `o` is `0`, then `coeff` becomes `0`.
#### Other comments
A test is added.
#### 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. If there is no release notes entry for this PR,
write "NO ENTRY". The bot will check your release notes automatically to see
if they are formatted correctly. -->
<!-- BEGIN RELEASE NOTES -->
* core
* fixed a bug about commutativity of Mul with AccumBounds
<!-- END RELEASE NOTES -->
I don't like more and more hard coding of special classes in Mul, but we don't have a good alternative dispatching system, so this will have to do for now.
This essentially treats AccumBounds as a Number, which, I think, is not unreasonable considering that also NaN is a Number. Maybe there could be a new property for "numerical type" objects that would cover both (unless AccumBounds can be made a subclass of Number). Then AccumBounds would not have to be explicitly imported in core. But, for now, it seems to me that this is best we can do.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References to other Issues or PRs
Fixes #13159
Brief description of what is fixed or changed
Changing the line 265 of
mul.py
in the following way:elif coeff.is_Number: # it could be zoo
(original line)elif coeff.is_Number or isinstance(coeff, AccumBounds): # it could be zoo
(modified)the code
is executed also in the case
coeff
isAccumBounds(-1, 1)
(or similar) and,in case
o
is0
, thencoeff
becomes0
.Other comments
A test is added.
Release Notes