From 6dc195df265f8777a727e1f60bf00ab2a9a0f765 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 29 Aug 2023 11:58:21 +0300 Subject: [PATCH 1/2] Implementation test logistic --- test_logistic.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test_logistic.py b/test_logistic.py index 9391bee..b5269b8 100644 --- a/test_logistic.py +++ b/test_logistic.py @@ -4,6 +4,16 @@ # Add here your test for the logistic map +def test_f_new_cases(): + 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) + def test_f_corner_cases(): # Test cases are (x, r, expected) From 02ec3c21b9be3936ef26b387b68d538f66d1014c Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 29 Aug 2023 12:25:21 +0300 Subject: [PATCH 2/2] Implementation of parametrization --- test_logistic.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test_logistic.py b/test_logistic.py index b5269b8..09477d9 100644 --- a/test_logistic.py +++ b/test_logistic.py @@ -1,19 +1,19 @@ from numpy.testing import assert_allclose - +import pytest from logistic import f # Add here your test for the logistic map -def test_f_new_cases(): - cases = [ +@pytest.mark.parametrize('x, r, expected', [ (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) - + ]) + +def test_f_generic_cases(x, r, expected): + result = f(x, r) + assert_allclose(result, expected) + def test_f_corner_cases(): # Test cases are (x, r, expected)