Logistic map tests #10
2 changed files with 13 additions and 0 deletions
|
@ -1 +1,4 @@
|
|||
# Your code goes here
|
||||
|
||||
def f(x, r):
|
||||
return r * x * (1 - x)
|
||||
|
|
|
@ -13,6 +13,16 @@ def test_f_corner_cases():
|
|||
result = f(x, r)
|
||||
assert_allclose(result, expected)
|
||||
|
||||
def test_f_generic_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)
|
||||
|
||||
# Hands on 1
|
||||
#Add a new test for these generic cases using the for-loop pattern:
|
||||
# x=0.1, r=2.2 => f(x, r)=0.198
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue