Skip to content

Commit

Permalink
avoid ZeroDivisionError
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulMelody committed Jan 25, 2025
1 parent 862fb39 commit 9c24d87
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libresvip/utils/music_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def f3(t: float, d: float) -> float:

@staticmethod
def slope(p1: tuple[float, float], p2: tuple[float, float]) -> float:
return (p2[1] - p1[1]) / (p2[0] - p1[0])
return (p2[1] - p1[1]) / (p2[0] - p1[0]) if p2[0] != p1[0] else math.nan

def slope_at(self, point_index: int) -> float:
if point_index in [0, len(self.points) - 1]:
Expand Down

0 comments on commit 9c24d87

Please sign in to comment.