mirror of
https://github.com/3b1b/manim.git
synced 2025-08-02 19:46:21 +08:00
Add conditions for resize_with_interpolation
This commit is contained in:
@ -101,6 +101,8 @@ def resize_preserving_order(nparray: np.ndarray, length: int) -> np.ndarray:
|
||||
def resize_with_interpolation(nparray: np.ndarray, length: int) -> np.ndarray:
|
||||
if len(nparray) == length:
|
||||
return nparray
|
||||
if len(nparray) == 1 or array_is_constant(nparray):
|
||||
return nparray[:1].repeat(length, axis=0)
|
||||
if length == 0:
|
||||
return np.zeros((0, *nparray.shape[1:]))
|
||||
cont_indices = np.linspace(0, len(nparray) - 1, length)
|
||||
@ -133,6 +135,7 @@ def arrays_match(arr1: np.ndarray, arr2: np.ndarray) -> bool:
|
||||
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([
|
||||
|
Reference in New Issue
Block a user