From 9c24d87360a2f43a4de350c8b5226cd032779677 Mon Sep 17 00:00:00 2001 From: SoulMelody Date: Sat, 25 Jan 2025 11:58:40 +0800 Subject: [PATCH] avoid ZeroDivisionError --- libresvip/utils/music_math.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libresvip/utils/music_math.py b/libresvip/utils/music_math.py index ad7f52f1..5963dc1b 100644 --- a/libresvip/utils/music_math.py +++ b/libresvip/utils/music_math.py @@ -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]: