Testing Class Material
This commit is contained in:
commit
05b1f6cdd5
85 changed files with 102796 additions and 0 deletions
10
hands_on/local_maxima_part2/local_maxima.py
Normal file
10
hands_on/local_maxima_part2/local_maxima.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
def find_maxima(x):
|
||||
"""Find local maxima of x.
|
||||
|
||||
Input arguments:
|
||||
x -- 1D list of real numbers
|
||||
|
||||
Output:
|
||||
idx -- list of indices of the local maxima in x
|
||||
"""
|
||||
return []
|
30
hands_on/local_maxima_part2/test_local_maxima.py
Normal file
30
hands_on/local_maxima_part2/test_local_maxima.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from local_maxima import find_maxima
|
||||
|
||||
|
||||
def test_find_maxima():
|
||||
values = [1, 3, -2, 0, 2, 1]
|
||||
expected = [1, 4]
|
||||
maxima = find_maxima(values)
|
||||
assert maxima == expected
|
||||
|
||||
|
||||
def test_find_maxima_edges():
|
||||
values = [4, 2, 1, 3, 1, 5]
|
||||
expected = [0, 3, 5]
|
||||
maxima = find_maxima(values)
|
||||
assert maxima == expected
|
||||
|
||||
|
||||
def test_find_maxima_empty():
|
||||
values = []
|
||||
expected = []
|
||||
maxima = find_maxima(values)
|
||||
assert maxima == expected
|
||||
|
||||
|
||||
def test_find_maxima_plateau():
|
||||
raise Exception('not yet implemented')
|
||||
|
||||
|
||||
def test_find_maxima_not_a_plateau():
|
||||
raise Exception('not yet implemented')
|
Loading…
Add table
Add a link
Reference in a new issue