mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Support hashing Color type in hash_obj
This commit is contained in:
parent
020bd87271
commit
09952756ce
1 changed files with 6 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from colour import Color
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
@ -79,7 +81,7 @@ def batch_by_property(
|
||||||
return batch_prop_pairs
|
return batch_prop_pairs
|
||||||
|
|
||||||
|
|
||||||
def listify(obj) -> list:
|
def listify(obj: object) -> list:
|
||||||
if isinstance(obj, str):
|
if isinstance(obj, str):
|
||||||
return [obj]
|
return [obj]
|
||||||
try:
|
try:
|
||||||
|
@ -139,4 +141,7 @@ def hash_obj(obj: object) -> int:
|
||||||
if isinstance(obj, (set, tuple, list)):
|
if isinstance(obj, (set, tuple, list)):
|
||||||
return hash(tuple(hash_obj(e) for e in obj))
|
return hash(tuple(hash_obj(e) for e in obj))
|
||||||
|
|
||||||
|
if isinstance(obj, Color):
|
||||||
|
return hash(obj.get_rgb())
|
||||||
|
|
||||||
return hash(obj)
|
return hash(obj)
|
||||||
|
|
Loading…
Add table
Reference in a new issue