mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
changed hashing
This commit is contained in:
parent
9d04e287d7
commit
aef02bfcf9
1 changed files with 14 additions and 8 deletions
|
@ -86,14 +86,20 @@ class DecimalNumber(VMobject):
|
||||||
return self.data["font_size"][0]
|
return self.data["font_size"][0]
|
||||||
|
|
||||||
def string_to_mob(self, string, mob_class=Text, **kwargs):
|
def string_to_mob(self, string, mob_class=Text, **kwargs):
|
||||||
if not kwargs:
|
def make_hash(o):
|
||||||
if string not in string_to_mob_map:
|
if isinstance(o, (set, tuple, list)):
|
||||||
string_to_mob_map[string] = mob_class(string, font_size=1, **kwargs)
|
return tuple([make_hash(e) for e in o])
|
||||||
mob = string_to_mob_map[string].copy()
|
elif not isinstance(o, dict):
|
||||||
else:
|
return hash(o)
|
||||||
if (string, str(kwargs)) not in string_to_mob_map:
|
from copy import deepcopy as _deepcopy
|
||||||
string_to_mob_map[(string, str(kwargs))] = mob_class(string, font_size=1, **kwargs)
|
new_o = _deepcopy(o)
|
||||||
mob = string_to_mob_map[(string, str(kwargs))].copy()
|
for k, v in new_o.items():
|
||||||
|
new_o[k] = make_hash(v)
|
||||||
|
return hash(tuple(frozenset(sorted(new_o.items()))))
|
||||||
|
|
||||||
|
if (string, make_hash(kwargs)) not in string_to_mob_map:
|
||||||
|
string_to_mob_map[(string, make_hash(kwargs))] = mob_class(string, font_size=1, **kwargs)
|
||||||
|
mob = string_to_mob_map[(string, make_hash(kwargs))].copy()
|
||||||
mob.scale(self.get_font_size())
|
mob.scale(self.get_font_size())
|
||||||
return mob
|
return mob
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue