Skip to content

Commit

Permalink
Add test for the area between two triangles
Browse files Browse the repository at this point in the history
This was pointed out by @mcnick as an obvious case where the
previous implementation has a mistate. There is nothing that
prevents the shoelace algorithm to be used with triangles.
  • Loading branch information
cjekel committed Oct 7, 2023
1 parent 75ee0c6 commit 6c1159e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ def test_mse(self):
mse = similaritymeasures.mse(exp_data, num_data)
self.assertTrue(np.isclose(mse, 0.41))

def test_area_triangle_1(self):
p = np.array([[0, 1, 2], [0, 1, 2]]).T
q = np.array([[0, 1, 2], [0, 0, 2]]).T
area = similaritymeasures.area_between_two_curves(p, q)
self.assertTrue(np.isclose(area, 1.0))

def test_area_triangle_2(self):
p = np.array([[0, 1, 2], [0, 1, 2]]).T
q = np.array([[0, 1, 2], [0, 0, 2]]).T
area = similaritymeasures.area_between_two_curves(q, p)
self.assertTrue(np.isclose(area, 1.0))


if __name__ == '__main__':

Expand Down

0 comments on commit 6c1159e

Please sign in to comment.