mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Add custom clip function, since np.clip is evidently super slow
This commit is contained in:
parent
67d9762773
commit
34a1896ea8
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue