Fix: Return correct index when time is up
This commit is contained in:
parent
46143e4717
commit
c3832725c5
@ -159,8 +159,10 @@ class LedScript:
|
||||
def _get_current_index(script, dt:float) -> int:
|
||||
if script.shape[0] == 1:
|
||||
return 0
|
||||
if dt > script["dtsum"][-1]: # if time is past the last index
|
||||
return script["dtsum"].shape[0] - 1
|
||||
distance = script["dtsum"] - dt
|
||||
idx = np.where(distance >= 0, distance, np.inf).argmin()
|
||||
idx = int(np.where(distance >= 0, distance, np.inf).argmin())
|
||||
return idx
|
||||
|
||||
def get_current_index(self, dt:float) -> int:
|
||||
|
Loading…
x
Reference in New Issue
Block a user