Skip to content

Commit 9e69877

Browse files
adds comments to tests to make task clearer
1 parent 5ff5136 commit 9e69877

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

hands_on/local_maxima_part3_debug/test_local_maxima.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,49 @@ def test_find_maxima_not_a_plateau():
4343

4444

4545
def test_find_maxima_correct_order():
46+
# TASK: get this test to pass
4647
values = [2, 1, 5, 1, 9]
4748
expected = [0, 2, 4]
4849
maxima = find_maxima(values)
4950
assert maxima == expected
5051

5152

5253
def test_find_maxima_one_value():
54+
# TASK: get this test to pass
5355
values = [1]
5456
expected = [0]
5557
maxima = find_maxima(values)
5658
assert maxima == expected
5759

5860

5961
def test_find_maxima_long_plateau():
60-
# Change find_maxima so that it returns the middle index of the plateau indices
62+
# TASK: Change the implementation for when there is a plateau
63+
# for uneven plateau length, return the middle index, e.g. [1, 2, *2*, 2, 1] --> [2]
64+
# for even plateau length, return the index left of the middle e.g. [1, 2, *2*, 2, 2, 1] --> [2]
6165
values = [1, 2, 2, 2, 2, 2, 1, 8, 0]
6266
expected = [3, 7]
6367
maxima = find_maxima(values)
6468
assert maxima == expected
6569

6670

6771
def test_find_maxima_plateau_at_end():
72+
# TASK: make sure plateaus at the end are handled properly (see test above)
6873
values = [1, 2, 2]
6974
expected = [1]
7075
maxima = find_maxima(values)
7176
assert maxima == expected
7277

7378

7479
def test_find_maxima_plateau_at_start():
80+
# TASK: make sure plateaus at the start are handled properly (see test above)
7581
values = [1, 1, 0, 0]
7682
expected = [0]
7783
maxima = find_maxima(values)
7884
assert maxima == expected
7985

8086

8187
def test_find_maxima_all_same_values():
88+
# TASK: implement a check for lists where there is no local maximum
8289
values = [1, 1]
8390
expected = [0]
8491
maxima = find_maxima(values)

0 commit comments

Comments
 (0)