Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

merge #6

Merged
merged 3 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
18 changes: 18 additions & 0 deletions tests/shapesimilarity/test_shape_similarity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from shapesimilarity import shape_similarity
import unittest

class TestShapeSimilarity(unittest.TestCase):
def test_returns_close_to_1_if_curves_have_similar_shapes(self):
curve1 = [[0, 0], [2, 4], [18, -3]]
curve2 = [[0.3, -0.2], [2.2, 4.5], [16, -4]]
self.assertEqual(shape_similarity(curve1, curve2), 0.9127)

def test_returns_low_numbers_for_curves_with_dissimilar_shapes(self):
curve1 = [[0, 0], [2, 4], [4, 0], [0, 0]]
curve2 = [[0, 0], [2, 2], [2, 2], [1, 1]]
self.assertEqual(shape_similarity(curve1, curve2), 0.4792)

def test_should_be_really_close_to_0_for_very_dissimilar_shapes(self):
curve1 = [[0, 0], [0.1, 0.1], [0.1, 0.1], [1, 1]]
curve2 = [[7, 7], [4, 4], [4, 4], [5, 5]]
self.assertEqual(shape_similarity(curve1, curve2), 0)