Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement logistic function and tests #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions logistic.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Your code goes here
def f(x,r):
return r*x*(1-x)
21 changes: 21 additions & 0 deletions test_logistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
from logistic import f

# Add here your test for the logistic map
def test_f_fixed_r_cases():
# Test cases are (x, r, expected)
cases = [
(1/3, 1.5, 1/3),
(2.7/3.7, 3.7, 2.7/3.7),
]
for x, r, expected in cases:
result = f(x, r)
assert_allclose(result, expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.7/3.7! who knew! :-D nice



def test_f_corner_cases():
Expand All @@ -14,3 +23,15 @@ def test_f_corner_cases():
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),

]
for x, r, expected in cases:
result = f(x, r)
assert_allclose(result, expected)