Skip to content

Commit

Permalink
Merge pull request #2 from OwenMastropietro/fix_issue_no1_number_of_l…
Browse files Browse the repository at this point in the history
…oops

fix issue #1 :: number_of_loops no longer modifies input image
  • Loading branch information
OwenMastropietro authored Jan 22, 2024
2 parents 6bf9ac0 + e678b1b commit 372f5ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def number_of_loops(image: ndarray) -> int:

assert isinstance(image, ndarray)

image = np.copy(image)

BLACK, WHITE = 0, 1
NUM_ROWS, NUM_COLS = len(image), len(image[0])

Expand Down
4 changes: 4 additions & 0 deletions test_feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@ def test_number_of_loops(self):

# test custom expected values
for digit, image in enumerate(self._images):
img_copy = image.copy()
self.assertEqual(number_of_loops(image),
self._number_of_loops[digit])
self.assertTrue(np.array_equal(image, img_copy),
'expected immutable image')

def test_horizontally_split_symmetry(self):
'''Tests the horizontally_split_symmetry function'''
Expand Down Expand Up @@ -348,5 +351,6 @@ def test_vertically_split_symmetry(self):
def test_get_image_features(self):
'''Tests the get_image_features function'''


if __name__ == '__main__':
unittest.main()

0 comments on commit 372f5ba

Please sign in to comment.