You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Miscellaneous Scene-Caching Optimisations and Bugfixes. (#315)
* fix 301/scene-caching optimization
* added nested dict with cirular references support
+ some docs
* optimization: now it ignores the scene object
* fix#320
* modified verbosity level
* added copy error handling
* fixed test_logging (maybe)
* captain black
* Various improvemens and optimizations,
Mostly about copys handling.
* yes sir I run black I swear sir
* ahem, typo
* (hopefully) fixed logging test
* Suggestion from the great @aathis
* Disable Scene Caching if `-` is filename.
Fix#348
* Import logger from proper place.
* Update expected log file
* added mappingproxy support
* fixed bug related when keys of the wrong format,
Now manim do really change the key to its hash. (wasn't really the case before)
* added large np array handling
* added message when using truncated array
* smolfix
* added unit test for hashing.py
* Fix a typo.
Co-authored-by: Leo Torres <[email protected]>
* Assign suggestions from @PgBiel
* suggestion from @leotrs
* Apply suggestions from code review
Co-authored-by: Pg Biel <[email protected]>
* fixed tests
* imrpoved code organization
* NO COLON NO COLON NO NO COLON NO LOCON NO COLON
Co-authored-by: Pg Biel <[email protected]>
* NO COLON NO COLON NO NO COLON NO LOCON NO COLON
Co-authored-by: Pg Biel <[email protected]>
Co-authored-by: Aathish Sivasubrahmanian <[email protected]>
Co-authored-by: Hugues Devimeux <[email protected]>
Co-authored-by: Leo Torres <[email protected]>
Co-authored-by: Pg Biel <[email protected]>
# We return the repr and not a list to avoid the JsonEncoder to iterate over it.
52
+
returnrepr(obj)
43
53
elifhasattr(obj, "__dict__"):
44
54
temp=getattr(obj, "__dict__")
45
-
returnself._encode_dict(temp)
55
+
# MappingProxy is not supported by the Json Encoder
56
+
ifisinstance(temp, MappingProxyType):
57
+
returndict(temp)
58
+
returnself._check_iterable(temp)
46
59
elifisinstance(obj, np.uint8):
47
60
returnint(obj)
48
-
try:
49
-
returnjson.JSONEncoder.default(self, obj)
50
-
exceptTypeError:
51
-
# This is used when the user enters an unknown type in CONFIG. Rather than throwing an error, we transform
52
-
# it into a string "Unsupported type for hashing" so that it won't affect the hash.
53
-
return"Unsupported type for hashing"
54
-
55
-
def_encode_dict(self, obj):
56
-
"""Clean dicts to be serialized : As dict keys must be of the type (str, int, float, bool), we have to change them when they are not of the right type.
57
-
To do that, if one is not of the good type we turn it into its hash using the same
58
-
method as all the objects here.
61
+
62
+
returnf"Unsupported type for serializing -> {str(type(obj))}"
63
+
64
+
def_handle_already_processed(self, obj):
65
+
"""Handle if an object has been already processed by checking the id of the object.
66
+
67
+
This prevents the mechanism to handle an object several times, and is used to prevent any circular reference.
59
68
60
69
Parameters
61
70
----------
62
71
obj : Any
63
-
The obj to be cleaned.
72
+
The obj to check.
64
73
65
74
Returns
66
75
-------
67
76
Any
68
-
The object cleaned following the processus above.
77
+
"already_processed" string if it has been processed, otherwise obj.
A string concatenation of the respective hashes of `camera_object`, `animations_list` and `current_mobjects_list`, separated by `_`.
141
224
"""
225
+
logger.debug("Hashing ...")
226
+
globalALREADY_PROCESSED_ID
227
+
# We add the scene object within the ALREADY_PROCESSED_ID, as we don't want to process because pretty much all of its attributes will be soon or later processed (in one of the three hashes).
"""Take a wait time, a boolean function as a stop condition and a list of mobjects, and then output their individual hashes. This is meant to be used for `scene.wait` function.
160
254
161
255
Parameters
162
256
-----------
257
+
scene_object : :class:`~.Scene`
258
+
The scene object.
259
+
camera_object : :class:`~.Camera`
260
+
The camera object.
163
261
wait_time : :class:`float`
164
262
The time to wait
165
-
166
263
stop_condition_function : Callable[[...], bool]
167
264
Boolean function used as a stop_condition in `wait`.
A concatenation of the respective hashes of `animations_list and `current_mobjects_list`, separated by `_`.
173
270
"""
271
+
logger.debug("Hashing ...")
272
+
t_start=perf_counter()
273
+
globalALREADY_PROCESSED_ID
274
+
# We add the scene object within the ALREADY_PROCESSED_ID, as we don't want to process because pretty much all of its attributes will be soon or later processed (in one of the three hashes).
0 commit comments