manim.utils.hashing

Utilities for scene caching.

Classes

CustomEncoder

Constructor for JSONEncoder, with sensible defaults.

Functions

get_camera_dict_for_hashing(camera_object)[source]

Remove some keys from camera_object.__dict__ that are very heavy and useless for the caching functionality.

Parameters

camera_object (Camera) – The camera object used in the scene

Returns

Camera.__dict__ but cleaned.

Return type

dict

get_hash_from_play_call(scene_object, camera_object, animations_list, current_mobjects_list)[source]

Take the list of animations and a list of mobjects and output their hashes. This is meant to be used for scene.play function.

Parameters
  • scene_object (Scene) – The scene object.

  • camera_object (Camera) – The camera object used in the scene.

  • animations_list (Iterable[Animation]) – The list of animations.

  • current_mobjects_list (Iterable[Mobject]) – The list of mobjects.

Returns

A string concatenation of the respective hashes of camera_object, animations_list and current_mobjects_list, separated by _.

Return type

str

get_hash_from_wait_call(scene_object, camera_object, wait_time, stop_condition_function, current_mobjects_list)[source]

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.

Parameters
  • scene_object (Scene) – The scene object.

  • camera_object (Camera) – The camera object.

  • wait_time (float) – The time to wait

  • stop_condition_function (Callable[[..], bool]) – Boolean function used as a stop_condition in wait.

Returns

A concatenation of the respective hashes of animations_list and `current_mobjects_list, separated by _.

Return type

str

get_json(obj)[source]

Recursively serialize object to JSON using the CustomEncoder class.

Parameters

dict_config (dict) – The dict to flatten

Returns

The flattened object

Return type

str