Skip to content
Merged
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
18 changes: 17 additions & 1 deletion exercises/saddle-points/saddle_points_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from saddle_points import saddle_points


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.3.0

class SaddlePointsTest(unittest.TestCase):
def test_identify_single_saddle_point(self):
Expand All @@ -20,6 +20,10 @@ def test_identify_single_saddle_point(self):
def test_empty_matrix_has_no_saddle_points(self):
self.assertEqual(saddle_points([]), set())

def test_matrix_with_one_elem_has_single_saddle_point(self):
matrix = [[1]]
self.assertEqual(saddle_points(matrix), set([(0, 0)]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not canonical, but I think it's a good one. Might not be a bad idea to create another PR in problem-specifications to add it there too, but I don't think this PR needs to be held up waiting on that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmccandless Oh. Yes. I forgot to remove that test. I had initially written it but then considered that the the issue was about NxM and it wasn't directly related so I didn't want to add extraneous tests to it.

I guess I should've asked first whether to include it or not but decided not to and forgot to remove it in this pull request.

Now that it has been merged... Should I create a new pull request in canonical with the same version number explaining that I'm adding that single element test or what should I do?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alexhans At this point, I would suggest making a new pull request in canonical, bumping the version number to 1.4.0 (because minor number is changed whenever tests are added/removed) and adding the 1x1 test.

def test_identify_lack_of_saddle_points_when_there_are_none(self):
matrix = [[1, 2, 3], [3, 1, 2], [2, 3, 1]]
self.assertEqual(saddle_points(matrix), set())
Expand All @@ -39,6 +43,18 @@ def test_identify_saddle_point_in_bottom_right_corner(self):
expected = set([(2, 2)])
self.assertEqual(saddle_points(matrix), expected)

def test_non_square_matrix_with_2_saddle_points(self):
matrix = [[3, 1, 3], [3, 2, 4]]
self.assertEqual(saddle_points(matrix), set([(0, 2), (0, 0)]))

def test_single_column_matrix_has_saddle_point_min_value(self):
matrix = [[2], [1], [4], [1]]
self.assertEqual(saddle_points(matrix), set([(1, 0), (3, 0)]))

def test_single_row_matrix_has_saddle_point_in_max_value(self):
matrix = [[2, 5, 3, 5]]
self.assertEqual(saddle_points(matrix), set([(0, 1), (0, 3)]))

# Additional tests for this track

def test_irregular_matrix(self):
Expand Down