From 536a6693c5fdd13d96c1f12db5d64301df3710a2 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 29 Aug 2023 12:06:53 +0300 Subject: [PATCH 1/2] expanded tests --- logistic.py | 4 +++- test_logistic.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/logistic.py b/logistic.py index e49d1c2..e9e8134 100644 --- a/logistic.py +++ b/logistic.py @@ -1 +1,3 @@ -# Your code goes here +def f(x , r): + """ Compute the logistic map for a given value of x and r """ + return r * x * (1 - x) diff --git a/test_logistic.py b/test_logistic.py index 9391bee..a50108a 100644 --- a/test_logistic.py +++ b/test_logistic.py @@ -4,12 +4,14 @@ # Add here your test for the logistic map - def test_f_corner_cases(): # Test cases are (x, r, expected) cases = [ (0, 1.1, 0), (1, 3.7, 0), + (0.1, 2.2, 0.198), + (0.2, 3.4, 0.544), + (0.5, 2, 0.5) ] for x, r, expected in cases: result = f(x, r) From f284d7f3039bd3046d1b12ed1914b59ebce1e521 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 29 Aug 2023 12:15:41 +0300 Subject: [PATCH 2/2] separate case tests --- logistic.py | 2 +- test_logistic.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/logistic.py b/logistic.py index e9e8134..5382c65 100644 --- a/logistic.py +++ b/logistic.py @@ -1,3 +1,3 @@ def f(x , r): - """ Compute the logistic map for a given value of x and r """ + """Compute the logistic map for a given value of x and r""" return r * x * (1 - x) diff --git a/test_logistic.py b/test_logistic.py index a50108a..142f64e 100644 --- a/test_logistic.py +++ b/test_logistic.py @@ -9,6 +9,15 @@ def test_f_corner_cases(): cases = [ (0, 1.1, 0), (1, 3.7, 0), + ] + for x, r, expected in cases: + result = f(x, r) + assert_allclose(result, expected) + + +def test_f_generic_cases(): + # Test cases are (x, r, expected) + cases = [ (0.1, 2.2, 0.198), (0.2, 3.4, 0.544), (0.5, 2, 0.5)