-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fixed bug in :class:~.NumberPlane
with strictly positive or strictly negative values for x_range
and y_range
#1744
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
for more information, see https://pre-commit.ci
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.
Thanks for the PR !
This needs a graphical unit test, given that it is a breaking bug.
I let a suggestion, please check it out !
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.
Thank you for handling this bug and for the descriptive code examples/explanation! The fix itself lgtm, but I left a suggestion to make the code simpler.
Also, a test should be added for this bug to ensure it doesn't pop up again. You can probably just use the examples in the PR description and count the number of lines produced.
Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com>
Ah, the checks are failing since I used |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
manim/mobject/coordinate_systems.py
Outdated
# self.x_lines = x_lines1 | ||
# self.y_lines = y_lines1 | ||
|
||
# For some reason the above is wrong |
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.
Is this supposed to be commented? 🤔 What does wrong mean here
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.
Hey hydrobeam, that was just when I was testing out how to set the attribute correctly. I have fixed it in the newest push.
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.
I fixed the broken text (and some bad typing) so this PR LGTM now.
~.NumberPlane
bug with positive/negative x_range
/y_range
values.
~.NumberPlane
bug with positive/negative x_range
/y_range
values.~.NumberPlane
with strictly positive or strictly negative values for x_range
and y_range
Changelog / Overview
Motivation
NumberPlane doesn't work correctly when you have two positive or two negative numbers set as the (x/y)_range.
generates an extra line:
The problem is here:
manim/manim/mobject/coordinate_systems.py
Lines 1594 to 1597 in 39d429d
Where you can see that in the above example that that the arange is going from 0 to 6 when it should really only have 6-2 = 4 elements.
This type of situation only arises when both the
x_min
andx_max
are either both positive or both negative, in my example they're both positive then we should only iterate up from 0 to 6-2=4. If they were both negative, say -6, -2 then we would iterate from -6-(-2) = -4 to 0.If you look at my changes you can see that I have implemented the above logic more generally, and left the code the same for when they are on both sides of 0.
We can now see that this fixes the error, and I have tested it for all possible combinations:
LineGraphExample.mp4
Explanation for Changes
Fixes a bug
Documentation Reference
Testing Status
Further Comments
Checklist
Reviewer Checklist