From db45d9e646ae0345218fe56cefe1d5ab6196fa35 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 16 Jan 2023 13:26:44 -0800 Subject: [PATCH] Add array_is_constant --- manimlib/utils/iterables.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manimlib/utils/iterables.py b/manimlib/utils/iterables.py index bbecbab9..e8880552 100644 --- a/manimlib/utils/iterables.py +++ b/manimlib/utils/iterables.py @@ -130,6 +130,9 @@ def arrays_match(arr1: np.ndarray, arr2: np.ndarray) -> bool: return arr1.shape == arr2.shape and (arr1 == arr2).all() +def array_is_constant(arr: np.ndarray) -> bool: + return len(arr) > 0 and not (arr - arr[0]).any() + def hash_obj(obj: object) -> int: if isinstance(obj, dict): return hash(tuple(sorted([