Exemplo n.º 1
0
    def test_merge_incompartible_trajs(self):
        """ Test the incompatible trajectories cause an exception to be raised """

        net1 = algebraic_net.copy()
        net2 = algebraic_net_assignment.copy()

        times1 = np.linspace(0, 15, 100)
        times2 = np.linspace(15, 25, 100)

        traj1 = Dynamics.integrate(net1, times1, fill_traj=False)
        traj2 = Dynamics.integrate(net2, times2, fill_traj=False)

        self.assertRaises(ValueError, traj1.merge, traj2)
Exemplo n.º 2
0
from __future__ import absolute_import
from builtins import range
import unittest
import os

import numpy as np

from SloppyCell.ReactionNetworks import *

from AlgTestNets import algebraic_net_assignment, algebraic_net

base_net = algebraic_net_assignment.copy()
base_net.remove_component('event0')
base_net.set_var_constant('k1', False)


class test_Trajectory(unittest.TestCase):
    def test_interpolate_basic(self):
        net = base_net.copy('test')
        traj = Dynamics.integrate(net, [0, 5.5, 15])
        traj.build_interpolated_traj()
        tlist_algebraic_net = np.array([0] + [0.8 * x for x in range(1, 15)])
        times, interp_traj = traj.evaluate_interpolated_traj(
            'X0', tlist_algebraic_net)

        self.assertAlmostEqual(interp_traj[1], 0.923116346390738, 5)
        self.assertAlmostEqual(interp_traj[4], .726149037073939, 5)
        self.assertAlmostEqual(interp_traj[6], 0.618783391805766, 5)
        self.assertAlmostEqual(interp_traj[8], 0.527292424043448, 5)
        self.assertAlmostEqual(interp_traj[10], 0.449328964119144, 5)
        self.assertAlmostEqual(interp_traj[14], 0.326279794615302, 5)