diff options
| author | Eddy Pedroni <epedroni@pm.me> | 2025-03-01 11:08:20 +0100 | 
|---|---|---|
| committer | Eddy Pedroni <epedroni@pm.me> | 2025-03-01 11:08:20 +0100 | 
| commit | c593f9635c941ba4a876fa2f3a5ecc734ce02e4d (patch) | |
| tree | 1a9f2b7bf98b59d71995924bd6ccd283d585d854 /solo-tool-project/src/solo_tool | |
| parent | 818859c4562a5f9fef4e74964ca31e4381ce6995 (diff) | |
Fix bugs in relative keypoint handler
Diffstat (limited to 'solo-tool-project/src/solo_tool')
| -rw-r--r-- | solo-tool-project/src/solo_tool/handlers.py | 9 | 
1 files changed, 5 insertions, 4 deletions
| diff --git a/solo-tool-project/src/solo_tool/handlers.py b/solo-tool-project/src/solo_tool/handlers.py index b178b3a..1820e86 100644 --- a/solo-tool-project/src/solo_tool/handlers.py +++ b/solo-tool-project/src/solo_tool/handlers.py @@ -56,14 +56,15 @@ def keyPointAbsolute(st: SoloTool, kp: float) -> Callable[[], None]:  def keyPointRelative(st: SoloTool, delta: int) -> Callable[[], None]:      from bisect import bisect_right, bisect_left      def f(): +        l = sorted(set(st.keyPoints + [st.keyPoint]))          if delta > 0: -            pivot = bisect_right(st.keyPoints, st.keyPoint) - 1 +            pivot = bisect_right(l, st.keyPoint) - 1          elif delta < 0: -            pivot = bisect_left(st.keyPoints, st.keyPoint) - 1 +            pivot = bisect_left(l, st.keyPoint)          else:              return -        new = max(min(pivot + delta, len(st.keyPoints) - 1), 0) -        st.keyPoint = st.keyPoints[new] +        new = max(min(pivot + delta, len(l) - 1), 0) +        st.keyPoint = l[new]      return f  def rateAbsolute(st: SoloTool, value: float) -> Callable[[], None]: | 
