diff --git a/curvepy/tests/test_utilities.py b/curvepy/tests/test_utilities.py index 13fd6fe7405b1da1a0efae919ae0185cdd593029..16803575e80d4bf03f4d177d3239f85c656ceddb 100644 --- a/curvepy/tests/test_utilities.py +++ b/curvepy/tests/test_utilities.py @@ -97,10 +97,10 @@ def test_ratio_is_0_when_a_is_b(): assert ratio(a, b, c) == 0 -def test_ratio_is_inf_when_a_is_c(): +def test_ratio_is_inf_when_b_is_c(): a = np.array([4, 3]) b = np.array([8, 5]) - c = a + c = b assert ratio(a, b, c) == np.NINF diff --git a/curvepy/utilities.py b/curvepy/utilities.py index 9550aaf7372c35e56e73a73bfa885da2c7148a21..dd6200ef3d11c22f906e02e4640cbfbd615db9b2 100644 --- a/curvepy/utilities.py +++ b/curvepy/utilities.py @@ -89,12 +89,11 @@ def ratio(left_point: np.ndarray, col_point: np.ndarray, right_point: np.ndarray if not collinear_check(left_point, col_point, right_point): raise ValueError("The points are not collinear!") - # TODO refactor me right - col != 0 for left, right, col in zip(left_point, right_point, col_point): - if left != right and right - col != 0: - return (col - left) / (right - col) - elif right - col == 0: + if right - col == 0: return np.NINF + elif left != right: + return (col - left) / (right - col) return 0