From 4674a165e16442345c3f12a823810b86c454d67e Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 23 Sep 2025 16:56:58 +0300 Subject: [PATCH] Best implementation so far --- testing_project/logistic.py | 3 ++- testing_project/test_logistic.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/testing_project/logistic.py b/testing_project/logistic.py index e49d1c2..a7926e7 100644 --- a/testing_project/logistic.py +++ b/testing_project/logistic.py @@ -1 +1,2 @@ -# Your code goes here +def f(x, r): + return r*x*(1-x) diff --git a/testing_project/test_logistic.py b/testing_project/test_logistic.py index 100d824..ad36c60 100644 --- a/testing_project/test_logistic.py +++ b/testing_project/test_logistic.py @@ -18,7 +18,16 @@ def test_f_corner_cases(): # x=0.1, r=2.2 => f(x, r)=0.198 # x=0.2, r=3.4 => f(x, r)=0.544 # x=0.5, r=2 => f(x, r)=0.5 - +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), + ] + for x, r, expected in cases: + result = f(x, r) + assert_allclose(result, expected) # Hands on 2: # parametrize the above test using @pytest.mark.parametrize