From 09952756ce817067f15b950addc3cec75c85d93c Mon Sep 17 00:00:00 2001 From: YishiMichael Date: Fri, 15 Apr 2022 13:48:24 +0800 Subject: [PATCH] Support hashing Color type in hash_obj --- manimlib/utils/iterables.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/manimlib/utils/iterables.py b/manimlib/utils/iterables.py index 05d92597..ecbdbc1a 100644 --- a/manimlib/utils/iterables.py +++ b/manimlib/utils/iterables.py @@ -1,5 +1,7 @@ from __future__ import annotations +from colour import Color + import numpy as np from typing import TYPE_CHECKING @@ -79,7 +81,7 @@ def batch_by_property( return batch_prop_pairs -def listify(obj) -> list: +def listify(obj: object) -> list: if isinstance(obj, str): return [obj] try: @@ -139,4 +141,7 @@ def hash_obj(obj: object) -> int: if isinstance(obj, (set, tuple, list)): return hash(tuple(hash_obj(e) for e in obj)) + if isinstance(obj, Color): + return hash(obj.get_rgb()) + return hash(obj)