Skip to content

Commit

Permalink
Raise error if points are identical
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Jun 25, 2024
1 parent b6744a5 commit a92866d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions maths.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import numpy as np


def equation_of_line(a, b):
"""
Determine the equation of the line passing through two points.
Expand All @@ -6,6 +9,8 @@ def equation_of_line(a, b):
:arg b: the second point the line passes through
:return: function of two variables defining the line
"""
if np.allclose(a, b):
raise ValueError("Cannot determine a unique line through {a} and {b}.")
x0, y0 = a
x1, y1 = b

Expand Down

0 comments on commit a92866d

Please sign in to comment.