Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎈 Motivation
IPython offers an
%autoreload all
magic command:This makes it possible for Manim users to make changes in imported files and see those changes reflected automatically without having to reload manually (by means of quitting and restarting the terminal, or by means of the new
reload()
command from #2251). Therefore, this PR improves the interactive experience with Manim fostering playful change of parameters/functions etc.💻 Proposed changes
--autoreload
CLI flag.InteractiveShellEmbed
shell is started.Note that
autoreload
should probably not be activated by default because it will slow down the performance since modules will be reloaded automatically and maybe even in cases where it wouldn't be necessary. Furthermore, we should be aware of the caveats that come withautoreload
. This is why I went for exposing it as flag that can be activated if users like to.🧪 Test
## B
) and get10
printed to the console.10
to42
inb.py
and save the file42
in the console, without having to reload manually 🎉Tip
Unfortunately, classes inside the same file won't be autoreloaded, just modules that are imported. E.g. see the evolute test example provided in #2240. So when defining custom classes that don't just host Manim rendering logic like
self.play()
etc., it might be worth to outsource such parts to another file when we want to work on them and make lots of changes. Otherwise, starting with #2251, thereload()
command such also work in such cases.If you want to reload classes from other modules, I just found this post.
📜 Documentation
I've added the CLI flag
--autoreload
to the docs.I also tried to build the docs but didn't succeed
I wanted to test this by following your instructions from here. Unfortunately, I stumbled into these issues:
Jinja
I first got this error and therefore downgraded Jinja:
Sphinx
Then I tried to run
make html
again which failed with:Realizing that
Sphinx==3.0.3
is specified indocs/requirements.txt
, I quit this pursuit to build the docs as I was not even sure it would work on your end...