-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
corrections for symbolic Range #21286
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
Conversation
✅ Hi, I am the SymPy bot (v161). 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.9. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
4f7c453
to
4e01170
Compare
Thanks for the correction. LGTM. |
nominal coverage is 100%; ready to commit when tests pass |
Range tries to be as lenient as possible in accepting symbolic limits but must then be careful to make no assumptions when being asked for elements of that Range. e.g. Range(x,x+5)[0] is not x unless we know that x is an integer; we also do not know that the size is 5 unless we know if x is an integer. If x == oo then this would be a null range.
ping @Sagar231 (if you want to take a look) |
References to other Issues or PRs
fixes #21269
Brief description of what is fixed or changed
Other comments
Symbolic Range is tricky because you can't assume that it isn't EmptSet when making queries like
.inf
, e.g. neitherRange(x,y,z).inf
nor Range(x,y,z)[0] can returnx
unless we know that (y - x)*z > 0And, technically, even
Range(x, x + 2, 1)[0]
should not returnx
unless we know that it is an integer.cf #21285 For better protection, a two more Mods could be added to give:
And(Eq(Mod(x,1),a%s), Eq(Mod(a,1),0), Eq(Mod(s,1),0))
wherea
is a representative point in the Range that is not infinite,s
is the step andx
is the relational variable. We should also make sure that there is not a clash between the symbols of the Range and the relational variable as inRange(x, x + 5, 2).as_relational(x)
.Release Notes
sup
) and errors will be raised when trying to compute attributes that are not known due to limitations of assumptions on the arguments.