Skip to content

Add classes MethodWithArgs, SceneInteractContinue and SceneInteractRerun inside new module manim.data_structures #4315

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

chopan050
Copy link
Contributor

@chopan050 chopan050 commented Jun 27, 2025

Overview: What does this pull request change?

  • Add classes MethodWithArgs, SceneInteractContinue and SceneInteractRerun. Currently, they all exist inside a new manim.data_structures file, although I intend to move SceneInteractContinue and SceneInteractRerun into scene.py if PR Move configure_pygui into a Scene method and remove manim.gui #4314 is merged first.
  • Make the items of Scene.queue, _AnimationBuilder.methods and _MethodAnimation.methods objects of these classes instead of tuples.

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

Scene.queue, _AnimationBuilder.methods and _MethodAnimation.methods contain tuples where the first element represents a method to be called, the second one is its args and the third one is its kwargs. Moreover, in the case of Scene.queue, the first element (a string) might not necessarily represent a method: it can be a key starting with "rerun" (in which case the args are not used and only some key-value pairs are extracted from the kwargs) or with "exit" (in which case neither the args nor the kwargs are used). On first sight, this might be very confusing. Previously, there were no docs for this behavior and I asked for them to be added in a comment I made while reviewing PR #4260. Now, I believe that it would be better if those were different objects from different classes altogether.

Links to added or changed documentation pages

I added data_structures.py to utilities_misc.rst, so now you can see the new MethodWithArgs structure in:
https://manimce--4315.org.readthedocs.build/en/4315/reference/manim.data_structures.html

The SceneInteractContinue and SceneInteractRerun classes are defined in:
https://manimce--4315.org.readthedocs.build/en/4315/reference/manim.scene.scene.html

The SceneInteractAction type alias was previously defined there as well. However, its docstring is not showing. Presumably, it's because it's indented inside the if TYPE_CHECKING: clause. It works fine when it's unindented.

Further Information and Comments

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

@chopan050 chopan050 marked this pull request as draft June 27, 2025 05:49
@chopan050 chopan050 marked this pull request as ready for review June 28, 2025 02:38
@chopan050 chopan050 changed the title Add classes MethodWithArgs, SceneInteractRerun and SceneInteractExit inside new module manim.data_structures Add classes MethodWithArgs, SceneInteractContinue and SceneInteractRerun inside new module manim.data_structures Jun 28, 2025
@chopan050
Copy link
Contributor Author

Note: it seems only "from_animation_number" from SceneInteractRerun.kwargs is being used. The other kwargs are unused. Thus, the structure could be simplified to directly contain an attribute .from_animation_number instead of .kwargs, but this requires discussion.

Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

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

This seems like a fine improvement and cleanup -- could you please just resolve the conflict / move the things you wanted to move first and then let me know (just re-request a review or ping me on Discord).

@github-project-automation github-project-automation bot moved this from 🆕 New to 👍 To be merged in Dev Board Jul 20, 2025
Comment on lines 1451 to +1453

kwargs = tup[2]
if "from_animation_number" in kwargs:
config["from_animation_number"] = kwargs[
if "from_animation_number" in action.kwargs:
config["from_animation_number"] = action.kwargs[

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@chopan050 chopan050 requested a review from behackl July 23, 2025 00:20
@chopan050
Copy link
Contributor Author

chopan050 commented Jul 23, 2025

This seems like a fine improvement and cleanup -- could you please just resolve the conflict / move the things you wanted to move first and then let me know (just re-request a review or ping me on Discord).

I just did, and I also added the data_structures.py file to docs/source/reference_index/utilities_misc.rst in order to render its docs in the website.

Note: the docstring of SceneInteractAction type alias, previously defined in scene.py, is not showing. Presumably, it's because the alias is indented inside the if TYPE_CHECKING: clause. It works fine when it's unindented. It can probably be fixed in a subsequent PR by modifying module_parsing.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👍 To be merged
Development

Successfully merging this pull request may close these issues.

2 participants