-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Two New Classes in geometry module: :class:.LabeledLine
and :class:.LabeledArrow
#3264
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
Two New Classes in geometry module: :class:.LabeledLine
and :class:.LabeledArrow
#3264
Conversation
…ry module testing suite
Merging changes into poetry config file from main branch
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.
Hi, thanks for the contribution! Overall, this is a solid PR as is, but I've made a few notes on type hints that should be included. The documentation built looks great and the test cases are nice to see of course.
Co-authored-by: Jason Villanueva <a@jsonvillanueva.com>
Co-authored-by: Jason Villanueva <a@jsonvillanueva.com>
Co-authored-by: Jason Villanueva <a@jsonvillanueva.com>
Co-authored-by: Jason Villanueva <a@jsonvillanueva.com>
for more information, see https://pre-commit.ci
will change name of labeled_shapes.py to labeled.py
Changed name of file from labeled_shapes.py to labeled.py and updated __init__.py to import from the correct location.
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.
Pending these suggested changes, lgtm!
Removed color import line because of redundancy. Co-authored-by: Jason Villanueva <a@jsonvillanueva.com>
default label_color parameter is now set to `None` instead of `WHITE`.
Co-authored-by: Jason Villanueva <a@jsonvillanueva.com>
Co-authored-by: Jason Villanueva <a@jsonvillanueva.com>
.LabeledLine
and :class:.LabeledArrow
SurroundingRectangle uses label_color as well and using a default of None removes the rectangle.
for more information, see https://pre-commit.ci
Also, thanks again @andresberejnoi for the contribution! If you're on the Manim Discord server and interested in having the |
Thank you, and I'm glad the contribution is useful. I will make sure to check out the Discord server again. |
Overview: What does this pull request change?
This PR adds two new classes:
LabeledLine
andLabeledArrow
.LabeledLine
inherits fromLine
and creates a line with a label and text box somewhere along its length. The position of the label, as well as the color and size can be controlled through parameters.LabeledArrow
inherits fromLabeledLine
andArrow
and allows to create arrows with a label somewhere along its length.I also added some basic tests under
tests/test_graphical_units/test_geometry.py
.I think these two classes belong in
line.py
, however, since they make use ofSurroundingRectangle
andBackgroundRectangle
, there is a circular import problem.SurroundingRectangle
andBackgroundRectangle
are inshape_matchers.py
which importsLine
fromline.py
. For this reason, I decided to create a new file containing my new classes:labeled.py
.Motivation and Explanation: Why and how do your changes improve the library?
I added these classes because I needed to create neural network animations that show weights between neurons. None of the tools already available were suitable for this task if I wanted to easily automate them. I think that lines or arrows with labels are very useful for diagrams and figures, so it would be nice to have them as part of the default package.
Here is a short video of what I am using these classes for:
NetworkWithRandomWeights.mp4
The label box can be moved anywhere along the length of the arrow or line, and in this case, I left it near the beginning.
Links to added or changed documentation pages
Further Information and Comments
Reviewer Checklist