Skip to content
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

Adding docs for VectorScene and LinearTransformationScene and reimplementing method #3681

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SirJamesClarkMaxwell
Copy link
Contributor

…, more information in PR comments

Overview: What does this pull request change?

Motivation and Explanation: Why and how do your changes improve the library?

When I worked in #3479 I noticed no examples for VectorScene and LinearTransformationScene, so I decided to change it.
During the writing example of the add_axes method, I noticed some bugs and its usage was quite limited. I decided to change it. I will add the reason for all changes in separate comments, in concrete changes.

Links to added or changed documentation pages

Further Information and Comments

please ignore the changes in get_pieces_movement I will remove them in the next commit, It was attached because I copied the code from another branch and forgot that they were there.

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@@ -79,20 +79,90 @@ def add_plane(self, animate: bool = False, **kwargs):
self.add(plane)
return plane

def add_axes(self, animate: bool = False, color: bool = WHITE, **kwargs):
def add_axes(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did I remove the color argument?

Because it is not working.
self.add_axes(color=RED) will not work, because the color of the VGroup is set before the axes creation.
I could add these lines:

if color:
    axes.set_color(color)

but I don't see the reason, the much more powerful would be the new solution when a user could use dictionaries to specify the exact all parameters in axes

Copy link
Contributor Author

@SirJamesClarkMaxwell SirJamesClarkMaxwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the purpose of the add_axes method if the user wants to add the axes. It could be done manually; it makes sense if this class has a specific list of objects. Same for add_plane method

def add_axes(
self,
animate: bool = False,
animation: Animation = Create,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

animation, animation_kwargs and play_kwargs

Why must a user be limited to the Create animation? -> Solution: my changes
It would annoy me if I wanted to create a more advanced animation but I would have only Create animation available.

self.wait()

"""
axis_kwargs = merge_dicts_recursively(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be marked in docs that there are default parameters for axis settings, and to change it the user have to pass it explicitly

Copy link
Contributor

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding lots of options for a simple animation, it would be better to just deprecate the method and have the user animate it themselves. EDIT: my mistake, I misunderstood the methods. If you want to do any custom animations, you should simply pass animate=False and do it yourself.

Also, please do not add the changes from #3675 here: that is a separate PR for a reason (git blame, if you're curious).

Comment on lines +86 to +89
animation_kwargs: dict[str, Any] | None = {},
play_kwargs: dict[str, Any] | None = {},
axis_config: dict[str, Any] | None = {},
**axis_kwargs: dict[str, Any] | None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
animation_kwargs: dict[str, Any] | None = {},
play_kwargs: dict[str, Any] | None = {},
axis_config: dict[str, Any] | None = {},
**axis_kwargs: dict[str, Any] | None,
animation_kwargs: dict[str, Any] = {},
play_kwargs: dict[str, Any] = {},
axis_config: dict[str, Any] = {},
**axis_kwargs: Any,

These are the correct typehints, as your code does not deal with the case of each parameter being None.
In addition to that, **kwargs is always typehinted as the type of the value of the dict.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I should identify the method of depreciation, remove them, and add examples for that, which will not be deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the following:

  1. add_plane
  2. add_axes
  3. add_vector
  4. position_x_coordinate
  5. position_y_coordinate
    and in LinearTransformationScene
    I would move the content of the add_vector (from the base class) into the body of the add_vector in the derived class.

If I understand, please let me know if I am wrong. Does the depreciation method mean deleting them from the source code? Right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After taking a look at the source code again, I will say that it's my mistake. These methods shouldn't be deprecated.
Instead of adding lots of parameters, the user should simply pass animate=False and then animate it themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean I should create as many code examples as possible?
Please explain a little bit about self.moving_mobjects member variable? What is this responsible for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means the implementation of the methods should be the same.
As for code examples, something like the following would suffice:

>>> from manim import LinearTransformationScene
>>> scene = LinearTransformationScene()
>>> scene.add_axes()
Axes(NumberLine, NumberLine)

@JasonGrace2282 JasonGrace2282 marked this pull request as draft April 21, 2024 15:00
@JasonGrace2282 JasonGrace2282 added the documentation Improvements or additions to documentation label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

None yet

2 participants