def test_expression_ICs(self): """Test math expression as IC""" test_net = net.copy() test_net.set_initial_var_value('x', 'A + 1.5*B') traj = test_net.integrate(np.linspace(0, 5, 5)) ICx = traj.getVariableTrajectory('x')[0] self.assertAlmostEqual(ICx, 4.0, 6, 'Failed on changing parameter IC')
def test_parameter_ics(self): """Test parameters as ICs""" test_net = net.copy() test_net.set_initial_var_value('x', 'A') traj = test_net.integrate(np.linspace(0, 5, 5)) ICx = traj.getVariableTrajectory('x')[0] self.assertAlmostEqual(ICx, 1.0, 6, 'Failed on parameter IC')
def test_resetting_initial_conditions(self): """Test resetting of ICs""" test_net = net.copy() test_net.set_initial_var_value('x', 0.5) traj = test_net.integrate(np.linspace(0, 5, 5)) ICx = traj.getVariableTrajectory('x')[0] self.assertAlmostEqual(ICx, 0.5, 6, 'Failed on resetting IC')
def test_resetting_parameter(self): """Test changing parameters as ICs""" test_net = net.copy() test_net.set_initial_var_value('x', 'A') test_net.set_initial_var_value('A', 0.9) traj = test_net.integrate(np.linspace(0, 5, 5)) ICx = traj.getVariableTrajectory('x')[0] self.assertAlmostEqual(ICx, 0.9, 6, 'Failed on changing parameter IC')
def test_default_initial_conditions(self): """Test that default ICs are handled correctly""" test_net = net.copy() traj = test_net.integrate(np.linspace(0, 5, 5)) ICx = traj.getVariableTrajectory('x')[0] ICy = traj.getVariableTrajectory('y')[0] self.assertAlmostEqual(ICx, 1.0, 6, 'Failed on default IC') self.assertAlmostEqual(ICy, 2.0, 6, 'Failed on default IC')
from __future__ import absolute_import from __future__ import division from past.utils import old_div import unittest import scipy import numpy as np from SloppyCell.ReactionNetworks import * from TestNetwork import net net = net.copy() net.setInitialVariableValue('A', 1.0) net.setInitialVariableValue('B', 2.0) net.addParameter('xIC', 4.0) net.setInitialVariableValue('x', '2.0*exp(xIC)') net.compile() class test_TimeDerivs(unittest.TestCase): def test_TimeDerivs(self): """Test time derivatives of the trajectory and the sensitivity trajectory """ net.add_int_times = False # need really finely spaced time points for the finite differencing to # work times = np.linspace(0.0, .001, 1000) Traj = Dynamics.integrate(net, times, return_derivs=True) sensTraj = Dynamics.integrate_sensitivity(net, times, return_derivs=True)