Commit graph

427 commits

Author SHA1 Message Date
Grant Sanderson
39fbb677dc
Have autoreload update shell namespace with reloaded module variables (#2278)
Some checks failed
docs / build up document and deploy (push) Has been cancelled
* Have autoreload update shell namespace with reloaded module variables

* Update comments
2024-12-13 13:23:50 -08:00
Grant Sanderson
f427fc67df
A few bug fixes (#2277)
* Comment tweak

* Directly print traceback

Since the shell.showtraceback is giving some issues

* Make InteracrtiveSceneEmbed into a class

This way it can keep track of it's internal shell; use of get_ipython has a finicky relationship with reloading.

* Move remaining checkpoint_paste logic into scene_embed.py

This involved making a few context managers for Scene: temp_record, temp_skip, temp_progress_bar, which seem useful in and of themselves.

* Change null key to be the empty string

* Ensure temporary svg paths for Text are deleted

* Remove unused dict_ops.py functions

* Remove break_into_partial_movies from file_writer configuration

* Rewrite guarantee_existence using Path

* Clean up SceneFileWriter

It had a number of vestigial functions no longer used, and some setup that could be made more organized.

* Remove --save_pngs CLI arg (which did nothing)

* Add --subdivide CLI arg

* Remove add_extension_if_not_present

* Remove get_sorted_integer_files

* Have find_file return Path

* Minor clean up

* Clean up num_tex_symbols

* Fix find_file

* Minor cleanup for extract_scene.py

* Add preview_frame_while_skipping option to scene config

* Use shell.showtraceback function

* Move keybindings to config, instead of in-place constants

* Replace DEGREES -> DEG

* Add arg to clear the cache

* Separate out full_tex_to_svg from tex_to_svg

And only cache to disk the results of full_tex_to_svg.  Otherwise, making edits to the tex_templates would not show up without clearing the cache.

* Bug fix in handling BlankScene

* Make checkpoint_states an instance variable of CheckpointManager

As per https://github.com/3b1b/manim/issues/2272

* Move resizing out of Window.focus, and into Window.init_for_scene

* Make default output directory "." instead of ""

To address https://github.com/3b1b/manim/issues/2261

* Remove input_file_path arg from SceneFileWriter

* Use Dict syntax in place of dict for config more consistently across config.py

* Simplify get_output_directory

* Swap order of preamble and additional preamble
2024-12-12 18:45:34 -08:00
Grant Sanderson
33dbf04985
Make checkpoint_states an instance variable of CheckpointManager (#2273)
As per https://github.com/3b1b/manim/issues/2272
2024-12-12 14:07:55 -08:00
Grant Sanderson
744e695340
Misc. clean up (#2269)
* Comment tweak

* Directly print traceback

Since the shell.showtraceback is giving some issues

* Make InteracrtiveSceneEmbed into a class

This way it can keep track of it's internal shell; use of get_ipython has a finicky relationship with reloading.

* Move remaining checkpoint_paste logic into scene_embed.py

This involved making a few context managers for Scene: temp_record, temp_skip, temp_progress_bar, which seem useful in and of themselves.

* Change null key to be the empty string

* Ensure temporary svg paths for Text are deleted

* Remove unused dict_ops.py functions

* Remove break_into_partial_movies from file_writer configuration

* Rewrite guarantee_existence using Path

* Clean up SceneFileWriter

It had a number of vestigial functions no longer used, and some setup that could be made more organized.

* Remove --save_pngs CLI arg (which did nothing)

* Add --subdivide CLI arg

* Remove add_extension_if_not_present

* Remove get_sorted_integer_files

* Have find_file return Path

* Minor clean up

* Clean up num_tex_symbols

* Fix find_file

* Minor cleanup for extract_scene.py

* Add preview_frame_while_skipping option to scene config

* Use shell.showtraceback function

* Move keybindings to config, instead of in-place constants

* Replace DEGREES -> DEG
2024-12-12 08:39:54 -08:00
Grant Sanderson
00b34f2020
Autoreload v2 (#2268)
Some checks are pending
docs / build up document and deploy (push) Waiting to run
* Add autoreload

* Typo correction

* Add --autoreload to configuration docts

Co-Authored-By: Splines <37160523+Splines@users.noreply.github.com>

---------

Co-authored-by: Splines <37160523+Splines@users.noreply.github.com>
2024-12-12 06:52:03 -08:00
Grant Sanderson
bafea89ac9
Update InteractiveSceneEmbed (#2267)
Some checks are pending
docs / build up document and deploy (push) Waiting to run
* Comment tweak

* Directly print traceback

Since the shell.showtraceback is giving some issues

* Make InteracrtiveSceneEmbed into a class

This way it can keep track of it's internal shell; use of get_ipython has a finicky relationship with reloading.

* Move remaining checkpoint_paste logic into scene_embed.py

This involved making a few context managers for Scene: temp_record, temp_skip, temp_progress_bar, which seem useful in and of themselves.

* Change null key to be the empty string
2024-12-11 11:33:48 -08:00
Grant Sanderson
6d753a297a Remove stray imports 2024-12-11 10:38:23 -06:00
Grant Sanderson
f9fc543b07 Merge branch 'master' of github.com:3b1b/manim into video-work 2024-12-11 10:36:52 -06:00
Grant Sanderson
13fdc9629d No need for the shortcuts into the manim_config 2024-12-11 09:58:51 -06:00
Grant Sanderson
fce92347fa Replace get_global_config() with manim_config, and make it an addict Dict 2024-12-11 09:50:17 -06:00
Varniex
5fcb668f07 fixing get_ipython import error 2024-12-11 16:40:56 +05:30
Grant Sanderson
9fcdd0de5f Use pyglet.window.key for key constant values 2024-12-10 20:00:03 -06:00
Grant Sanderson
9f785a5fba Move key to int constants to interactive_scene.py 2024-12-10 19:42:53 -06:00
Grant Sanderson
f9a44c9975 Make ffmpeg_bin specification a piece of file_writer_config 2024-12-10 19:29:55 -06:00
Grant Sanderson
c9b6ee57a8 Make default_wait_time a piece of scene configuration 2024-12-10 19:21:16 -06:00
Grant Sanderson
32d36a09f6 Update commend on reload_scene 2024-12-10 15:46:34 -06:00
Grant Sanderson
d21fbd02bc Minor tweak to reload_scene 2024-12-10 14:46:03 -06:00
Grant Sanderson
ae93d8fcc6 Move update to is_reload status of run_config out of ReloadManager 2024-12-10 14:42:53 -06:00
Grant Sanderson
1d67768a13 Move reload out of Scene, instead have it directly update the global run configuration 2024-12-10 14:34:46 -06:00
Grant Sanderson
f9fa8ac846 Make scene configuration part of the global configuration 2024-12-10 13:58:03 -06:00
Grant Sanderson
bcc4235e2f Move embed configuration out of Scene, and get rid of error sound option 2024-12-10 12:43:29 -06:00
Grant Sanderson
7a69807ce6 Remove mobject.save_to_file
This simply didn't work, and had no resilience to changes to the library. For cases where this might be useful, it's likely much better deliberately save specific data which is time-consuming to generate on the fly.
2024-12-09 16:24:50 -06:00
Grant Sanderson
bf81d94362 Don't make reload_manager a global variable 2024-12-09 15:54:16 -06:00
Grant Sanderson
5b315d5c70 Get rid of the (hacky) solution to redefining Scene methods, since reload handles it better 2024-12-09 14:02:22 -06:00
Grant Sanderson
cb3e115a6c Minor cleaning 2024-12-09 14:01:34 -06:00
Grant Sanderson
40b5c7c1c1 Slightly clean up interactive_scene_embed 2024-12-09 13:56:33 -06:00
Grant Sanderson
636fb3a45b Factor interactive embed logic out of Scene class 2024-12-09 13:53:03 -06:00
Grant Sanderson
89bf0b1297 Track all mobjects as a set in Scene. begin_animations 2024-12-07 08:21:33 -07:00
Grant Sanderson
dd251ab8c2 Remove "preview" as a scene parameter, just look for whether window is None 2024-12-06 09:54:14 -06:00
Grant Sanderson
53b6c34ebe Create Window outside of Scene, and pass it in as an argument 2024-12-06 09:39:12 -06:00
Grant Sanderson
49c2b5cfe0 Check if animation.mobject is in the full family of scene mobjects before adding 2024-12-06 08:51:08 -06:00
Splines
6196daa5ec
Reload user-defined modules during reload() (#2257)
* Experiment a lot with module loading

* Extract methods out of experimental mess

* Fix get module return type

* Only reload() modules during reload() command

* Remove unnecessary default parameter

* Add docstrings and logging statements

* Delete unwanted printout

* Improve logging messages

* Extract methods to a new class ModuleLoader

* Remove unused builtins import

* exec_module in any case at the end

* Clarify docstrings & move get_module method up in file

* Add more additionally excluded modules as array

* Distinguish between user-defined modules and external libraries like numpy

* Improved tracked_import docstring

* Remove _insert_embed suffix before logging

* Fix args.is_reload not defined error

* Refine logic to determine whether module is user-defined or not

* Fix list vs. set type annotations

* Improve docstrings & change order of early return

* Fix spelling mistake of "Reloading"

* Try out custom deep reload

* Make deep reload more robust

* Also reload modules imported as classes

* Move early return up to greatly improve performance

* Clean up comments

* Make methods of Module Loader "private"

* Add backticks around function in docstring

---------

Co-authored-by: Grant Sanderson <grant@3blue1brown.com>
2024-12-05 16:18:10 -08:00
Grant Sanderson
94f6f0aa96
Cleaner local caching of Tex/Text data, and partially cleaned up configuration (#2259)
* Remove print("Reloading...")

* Change where exception mode is set, to be quieter

* Add default fallback monitor for when no monitors are detected

* Have StringMobject work with svg strings rather than necessarily writing to file

Change SVGMobject to allow taking in a string of svg code as an input

* Add caching functionality, and have Tex and Text both use it for saved svg strings

* Clean up tex_file_writing

* Get rid of get_tex_dir and get_text_dir

* Allow for a configurable cache location

* Make caching on disk a decorator, and update implementations for Tex and Text mobjects

* Remove stray prints

* Clean up how configuration is handled

In principle, all we need here is that manim looks to the default_config.yaml file, and updates it based on any local configuration files, whether in the current working directory or as specified by a CLI argument.

* Make the default size for hash_string an option

* Remove utils/customization.py

* Remove stray prints

* Consolidate camera configuration

This is still not optimal, but at least makes clearer the way that importing from constants.py kicks off some of the configuration code.

* Factor out configuration to be passed into a scene vs. that used to run a scene

* Use newer extract_scene.main interface

* Add clarifying message to note what exactly is being reloaded

* Minor clean up

* Minor clean up

* If it's worth caching to disk, then might as well do so in memory too during development

* No longer any need for custom hash_seeds in Tex and Text

* Remove display_during_execution

* Get rid of (no longer used) mobject_data directory reference

* Remove get_downloads_dir reference from register_font

* Update where downloads go

* Easier use of subdirectories in configuration

* Add new pip requirements
2024-12-05 14:51:14 -08:00
Varniex
5d3f730824
Cleaning up some imports + Minor Bug fixed in VectorField (#2253)
* cleaning up imports

* sample_points -> sample_coords
2024-12-05 14:42:46 -08:00
Splines
1fa17030a2
Add reload() command for interactive scene reloading (#2240)
* Init reload command (lots of things not working yet)

* Add back in class line (accidentally deleted)

* Add back in key modifiers (accidentally deleted)

* Unpack tuple from changed `get_module`

* Init MainRunManager & respawn IPython shell

* Init cleanup of scenes from manager

* Restore string quotes

* Still take `self.preview` into account

* Remove left-over code from module experimentation

* Remove double window activation

* Reset scenes array in RunManager

* Move self.args None check up

* Use first available window

* Don't use constructor for RunManager

* Use self. syntax

* Init moderngl context manually

* Add some comments for failed attempts to reset scene

* Reuse existing shell (this fixed the bug 🎉)

* Remove unused code

* Remove unnecessary intermediate ReloadSceneException

* Allow users to finally exit

* Rename main_run_manager to reload_manager

* Add docstrings to `ReloadManager`

* Improve reset management in window

* Clarify why we use magic exit_raise command

* Add comment about window reuse

* Improve docstrings in ReloadManager & handle case of 0 scenes

* Set scene and title earlier

* Run linter suggestions
2024-11-26 10:09:43 -08:00
Grant Sanderson
1248abd922
Merge pull request #2233 from mitkonikov/modifier-keys-fix
Properly check modifier keys.
2024-11-25 10:09:10 -06:00
Splines
af923a2327
Add docstring to user-facing focus() method 2024-11-10 19:10:53 +01:00
Splines
97b6e39abb
Init new focus() command 2024-11-10 18:48:33 +01:00
MathItYT
693a859caf revert changes in mobject.py and camera.py 2024-10-27 14:10:12 -03:00
MathItYT
1738876f43 fix bad 3D overlapping using z_index 2024-10-27 14:06:35 -03:00
Mitko Nikov
dc731f8bf2 Properly check modifier keys. 2024-10-25 00:01:30 +02:00
Pedro Fonini
2dd0256af6
Instantiate the IPython shell without a local ns 2024-10-12 22:02:43 -03:00
Grant Sanderson
81b17dd63e
Merge pull request #2168 from zhujisheng/patch-1
Update scene.py to make scene.time more accurate
2024-10-10 12:24:05 -07:00
Grant Sanderson
154a473a12 Get rid of globals update locals hack
It seems this issues is no longer there in the case of list constructors(?). Although it still exists for functions defined within a cell, that can be circumvented with more explicit function arguments.
2024-10-10 14:05:43 -05:00
Grant Sanderson
29cb6f76fe Write scene insertions into a subdirectory 2024-10-02 07:24:33 -05:00
Grant Sanderson
cf37f34e1f Add copy cursor position option 2024-10-01 13:05:00 -05:00
zhujisheng
ccb9977a67
Update scene.py to make scene.time more accurate
When the time intervals are (0, dt, 2dt, ...), during the first frame processing, only the video is inserted, but the update parameter is 0, which causes scene.time to be inaccurate. The correct time intervals should be (dt, 2dt, ...)
2024-09-23 23:48:18 +08:00
Grant Sanderson
1f55832a6a Clean up around z_index 2024-09-06 12:20:26 -05:00
Grant Sanderson
aebf2220a6
Merge pull request #2057 from germanzhu/add-zorder-mobject
add zorder to mobject
2024-09-06 10:11:40 -07:00
Grant Sanderson
08f7cb8d3e
zorder -> z_index 2024-09-06 10:11:31 -07:00