Commit graph

6279 commits

Author SHA1 Message Date
Grant Sanderson
e270f5c3d3 Change from get_module_with_inserted_embed_line to insert_embed_line_to_module
Rather than taking in a file_name and reading it in, directly take the module and edit its code.
2024-12-06 11:59:18 -07:00
Grant Sanderson
fadd045fc1 Don't write new file when inserting embed line
Instead, load the relevant module of the true file, and execute the modified code within that.

This also cleans up some of the previous now-unnecessary code around get_module_with_inserted_embed_line
2024-12-06 11:05:57 -07:00
Grant Sanderson
dd0aa14442 Clean up get_module_with_inserted_embed_line, only accept line number as embed arg 2024-12-06 10:39:02 -06:00
Grant Sanderson
d357e21c1d Change how ModuleLoader receives is_reload information
Use on the fly import of reload_manager rather than altering the args
2024-12-06 10:07:07 -06: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
2e49c60148 Use config.get_resolution for constants 2024-12-06 09:49:21 -06:00
Grant Sanderson
33c7f6d063 Factor out resolution from get_camera_config 2024-12-06 09:46:26 -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
Grant Sanderson
09fb8d324e Merge branch 'master' of github.com:3b1b/manim into video-work 2024-12-05 18:18:28 -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
e05cae6775 Merge branch 'master' of github.com:3b1b/manim into video-work 2024-12-05 16:51:35 -06: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
Grant Sanderson
0e83c9c0d9
Merge branch 'master' into video-work 2024-12-05 16:50:13 -06:00
Iñaki Rabanillo
5a70d67b98
Update coordinate_systems.py (#2258) 2024-12-05 14:49:16 -08:00
henri-gasc
66862db9b2
Drop pyrr (#2256) 2024-12-05 14:43: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
Grant Sanderson
3cd3e8cedc Add new pip requirements 2024-12-05 15:56:29 -06:00
Grant Sanderson
08acfa6f1f Easier use of subdirectories in configuration 2024-12-05 15:52:39 -06:00
Grant Sanderson
75527563de Update where downloads go 2024-12-05 15:27:57 -06:00
Grant Sanderson
c96734ace0 Remove get_downloads_dir reference from register_font 2024-12-05 15:14:37 -06:00
Grant Sanderson
71e440be93 Get rid of (no longer used) mobject_data directory reference 2024-12-05 15:08:25 -06:00
Grant Sanderson
8098149006 Remove display_during_execution 2024-12-05 15:05:37 -06:00
Grant Sanderson
4251ff436a No longer any need for custom hash_seeds in Tex and Text 2024-12-05 15:05:26 -06:00
Grant Sanderson
85f8456228 If it's worth caching to disk, then might as well do so in memory too during development 2024-12-05 14:56:35 -06:00
Grant Sanderson
e0031c63bc Minor clean up 2024-12-05 14:55:28 -06:00
Grant Sanderson
361d9d0652 Minor clean up 2024-12-05 14:42:22 -06:00
Grant Sanderson
1d14bae092 Add clarifying message to note what exactly is being reloaded 2024-12-05 14:37:14 -06:00
Grant Sanderson
8dfd4c1c4e Use newer extract_scene.main interface 2024-12-05 14:36:43 -06:00
Grant Sanderson
96a4a4b76f Factor out configuration to be passed into a scene vs. that used to run a scene 2024-12-05 14:36:21 -06:00
Grant Sanderson
0496402c55 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.
2024-12-05 14:17:53 -06:00
Grant Sanderson
fc32f162a0 Remove stray prints 2024-12-05 13:46:47 -06:00
Grant Sanderson
3b9ef57b22 Remove utils/customization.py 2024-12-05 11:59:01 -06:00
Grant Sanderson
b593cde317 Make the default size for hash_string an option 2024-12-05 11:53:55 -06:00
Grant Sanderson
34ad61d013 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.
2024-12-05 11:53:18 -06:00
Grant Sanderson
cfb7d2fa47 Remove stray prints 2024-12-05 10:09:48 -06:00
Grant Sanderson
43821ab2ba Make caching on disk a decorator, and update implementations for Tex and Text mobjects 2024-12-05 10:09:15 -06:00
Grant Sanderson
89ddfadf6b Allow for a configurable cache location 2024-12-04 20:50:42 -06:00
Grant Sanderson
0c385e820f Get rid of get_tex_dir and get_text_dir 2024-12-04 20:33:43 -06:00
Grant Sanderson
ac01b144e8 Clean up tex_file_writing 2024-12-04 20:30:53 -06:00
Grant Sanderson
129e512b0c Add caching functionality, and have Tex and Text both use it for saved svg strings 2024-12-04 19:51:01 -06:00
Grant Sanderson
88370d4d5d 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
2024-12-04 19:11:21 -06:00
Grant Sanderson
671a31b298 Add default fallback monitor for when no monitors are detected 2024-12-03 15:14:48 -06:00
Grant Sanderson
f8280a12be Change where exception mode is set, to be quieter 2024-11-30 10:08:54 -06:00
Grant Sanderson
d78fe93743 Remove print("Reloading...") 2024-11-30 10:08:41 -06:00
Anon
8239f1bf35
Update README.md for better readability (#2246) 2024-11-26 10:11:04 -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
530cb4f104
Merge pull request #2250 from 3b1b/video-work
Video work
2024-11-25 13:44:08 -06:00
Grant Sanderson
85638d88dc Update parameter range for sphere 2024-11-25 12:39:41 -07:00
Grant Sanderson
fbce0b132c Temporary band-aide for degenerate normal vector calculations
This solution is a bit too specific to the case of spheres.
2024-11-25 12:39:32 -07:00