-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix bug and rename :meth:vector_coordinate_label to :meth:~.Vector.coordinate_label and move it to :class:geometry.py
#1407
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
Fix bug and rename :meth:vector_coordinate_label to :meth:~.Vector.coordinate_label and move it to :class:geometry.py
#1407
Conversation
vector_coordinate_label and move it to :class:~.geometry.pyvector_coordinate_label and move it to :class:~.geometry.py
behackl
left a comment
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.
Overall this looks good to me, thanks for improving the implementation! I have one suggestion, please have a look and ping me once you have applied it (or want to discuss it).
I think that this PR fixes issues that the old implementation had, but at the same time it would be nice to have the option to have a background rectangle added -- maybe via an additional keyword parameter. It would also be a good first issue, could you simply open an issue for it and reference this PR?
manim/mobject/geometry.py
Outdated
| def coordinate_label(self, integer_labels=True, n_dim=2, color=WHITE): | ||
| """A label based on the coordinates of the vector. | ||
| Parameters | ||
| ---------- | ||
| integer_labels : :class:`bool`, optional | ||
| Whether or not to round the coordinates to integers. | ||
| n_dim : `class`:`int`, optional | ||
| The number of dimensions of the vector. | ||
| color : :class:`~.Colors`, optional | ||
| The color of the label. |
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'd rather have the types as actual type hints. Also, I'm pretty sure that WHITE is just a str.
| def coordinate_label(self, integer_labels=True, n_dim=2, color=WHITE): | |
| """A label based on the coordinates of the vector. | |
| Parameters | |
| ---------- | |
| integer_labels : :class:`bool`, optional | |
| Whether or not to round the coordinates to integers. | |
| n_dim : `class`:`int`, optional | |
| The number of dimensions of the vector. | |
| color : :class:`~.Colors`, optional | |
| The color of the label. | |
| def coordinate_label(self, integer_labels: bool = True, n_dim : int = 2, color: str = WHITE): | |
| """A label based on the coordinates of the vector. | |
| Parameters | |
| ---------- | |
| integer_labels | |
| Whether or not to round the coordinates to integers. | |
| n_dim | |
| The number of dimensions of the vector. | |
| color | |
| The color of the label. |
|
I've implemented your suggestions, so it should be good to go! @behackl |
vector_coordinate_label and move it to :class:~.geometry.pyvector_coordinate_label and move it to :class:geometry.py
vector_coordinate_label and move it to :class:geometry.pyvector_coordinate_label to :meth:~.Vector.coordinate_label and move it to :class:geometry.py
Changelog / Overview
Fix odd visuals and unnecessary functionality in
vector_coordinate_labeland move it to geometry.py as a method underVector. Also includes compatibility forvector_space_sceneMotivation
BackgroundRectanglewas raising some errors forvector_coordinate_labelwhen animated with self.play(), so I removed its usages from this method since I couldn't find a reason for why it was there. Also, I removed theadd_background_rectangles_to_entries=Truefrom the method since it introduced some very odd looking labels.Explanation for Changes
Usually, a label for a vector would be called by
vector_coordinate_labeland through passing aVectormobject as the first argument (technically it could have been anyLine). This makes the method explicitly attached toVectorand removes some useless functionality which causes errors and visual mishaps.Old:
New:
Testing Status
Further Comments
The reason for the bug actually lies in
BackgroundRectangle. This PR is simply intended to patch a rather useful method.Checklist
Reviewer Checklist