Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

Scientific Computing Midterm

Views: 873
1
from attractor import Attractor
2
from nose import with_setup
3
import numpy as np
4
5
###
6
# Test Suite for specified Attractor interface
7
#
8
# Run with the command: "nosetests attractor.py"
9
###
10
11
def test_dt():
12
""" Our first test will be to ensure that our time increment, dt, is being properly calculated.
13
If this test fails we will be warned that there was a calculation error."""
14
a = Attractor()
15
assert a.end == a.dt * a.points, "\n There was a problem calculating the time increment! \n"
16
17
def test_euler():
18
""" This test case is to ensure proper size of the value returned by our euler method.
19
If this test fails it will indicate that there aren't the correct number of items being passed
20
to the method."""
21
a = Attractor()
22
xyz = np.array([0.0,0.0,0.0])
23
assert a.euler(xyz).shape == (3, ), "\n The array given to the euler method did not contain 3 items!\n"
24
25
def test_evolve():
26
""" This test case is to ensure proper number of parameters are being passed to the evolve method. As
27
above, this test also check for proper passing of paramters."""
28
a = Attractor()
29
assert a.evolve().shape == (a.points, 4), "\n The array given to the evolve method was improper!\n"
30