From 173f5bbbe108f9bc077651245c257890ada2df22 Mon Sep 17 00:00:00 2001 From: Mayar Ali Date: Tue, 10 Apr 2018 10:05:56 +0200 Subject: [PATCH 1/2] added tests file --- tests.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests.py diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..56146df --- /dev/null +++ b/tests.py @@ -0,0 +1,24 @@ +import numpy as np +import matplotlib.pyplot as plt +from maxima import find_maxima + + +def test_maxima(x, y, fn): + result = (y == fn(x)) + print('x =', x, ', result:', result) + if(not result): + print('expected:', y, ', but found:', find_maxima(y1)) + + +x1 = [0, 1, 2, 1, 2, 1, 0] +y1 = [2, 4] +test_maxima(x1, y1, find_maxima) +x2 = [4, 2, 1, 3, 1, 2] +y2 = [3] +test_maxima(x2, y2, find_maxima) +x3 = [1, 3, 2, 2, 1] +y3 = [1] +test_maxima(x3, y3, find_maxima) +x4 = [1, 2, 2, 1] +y4 = [1, 2] +test_maxima(x4, y4, find_maxima) From a53c305635173b3e8981945f8280d073d8b04aa7 Mon Sep 17 00:00:00 2001 From: Mayar Ali Date: Tue, 10 Apr 2018 10:08:53 +0200 Subject: [PATCH 2/2] Fixed bugs --- tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests.py b/tests.py index 56146df..4a386b5 100644 --- a/tests.py +++ b/tests.py @@ -1,5 +1,4 @@ import numpy as np -import matplotlib.pyplot as plt from maxima import find_maxima @@ -7,7 +6,7 @@ def test_maxima(x, y, fn): result = (y == fn(x)) print('x =', x, ', result:', result) if(not result): - print('expected:', y, ', but found:', find_maxima(y1)) + print('expected:', y, ', but found:', find_maxima(y)) x1 = [0, 1, 2, 1, 2, 1, 0]