mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 05:52:34 +08:00
Add custom clip function, since np.clip is evidently super slow
This commit is contained in:
@ -45,6 +45,14 @@ def get_parameters(function):
|
||||
# but for now, we just allow the option to handle indeterminate 0/0.
|
||||
|
||||
|
||||
def clip(a, min_a, max_a):
|
||||
if a < min_a:
|
||||
return min_a
|
||||
elif a > max_a:
|
||||
return max_a
|
||||
return a
|
||||
|
||||
|
||||
def clip_in_place(array, min_val=None, max_val=None):
|
||||
if max_val is not None:
|
||||
array[array > max_val] = max_val
|
||||
|
Reference in New Issue
Block a user