-
Couldn't load subscription status.
- Fork 2.5k
Raise appropriate errors in :meth:~.VMobject.point_from_proportion
#1302
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
Raise appropriate errors in :meth:~.VMobject.point_from_proportion
#1302
Conversation
VMobject.point_from_proportion~.VMobject.point_from_proportion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I've written some suggestions to improve UX on the site (back links to VMobject)... Unfortunately, OpenGLVMobject isn't indexed on our docs so the same stuff doesn't apply in opengl_vectorized_mobject.py.
I did want to briefly ask though, why not clamp the value between 0-1 as is done in other parts of the library (e.g. animations/clamping dt) instead of raising an error?
|
I'd say that if someone passes a proportion that's greater than 1 or less than 0, then either the code that passes the invalid proportion is bugged, or they understand the method wrong, both of which warrant an error. If they wish to have it clamped, then they can clamp the value themselves when passing it. |
|
I improved the docs, and just used (also you merged master into my branch just as I was about to push so that's why there's an extra commit) |
|
The RTD build failing is not my fault afaict |
Changelog / Overview
alphaargument is not between 0 and 1.~.VMobjecthas no points.Motivation
This will lead to less cryptic errors to users who use
VMobject.point_from_proportionin the above ways. Currently it will just returnNonein those situations which makes it a bit tricky to track down the error. The previous implementation (before #1274) would have raised an error about it going beyond the number of its curves.Explanation for Changes
Before doing any calculations, it's checked if
alphais between 0 and 1, and if not aValueErroris raised. Then.throw_error_if_no_points()is called which will raise an error with an appropriate message (though it's just a plainException).I've also improved the method's docs and added accompanying tests.
Testing Status
Tests pass and docs look good locally.
Checklist
Reviewer Checklist