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