Scientific Computing Midterm
from attractor import Attractor1from nose import with_setup2import numpy as np34###5# Test Suite for specified Attractor interface6#7# Run with the command: "nosetests attractor.py"8###910def test_dt():11""" Our first test will be to ensure that our time increment, dt, is being properly calculated.12If this test fails we will be warned that there was a calculation error."""13a = Attractor()14assert a.end == a.dt * a.points, "\n There was a problem calculating the time increment! \n"1516def test_euler():17""" This test case is to ensure proper size of the value returned by our euler method.18If this test fails it will indicate that there aren't the correct number of items being passed19to the method."""20a = Attractor()21xyz = np.array([0.0,0.0,0.0])22assert a.euler(xyz).shape == (3, ), "\n The array given to the euler method did not contain 3 items!\n"2324def test_evolve():25""" This test case is to ensure proper number of parameters are being passed to the evolve method. As26above, this test also check for proper passing of paramters."""27a = Attractor()28assert a.evolve().shape == (a.points, 4), "\n The array given to the evolve method was improper!\n"2930