コード例 #1
0
    def test_history_bound_and_clamp(self):
        from .models_test import TestBoundsModel
        test_simulator = simulator.Simulator()
        test_simulator.model = TestBoundsModel()
        test_simulator.model.configure()
        self._config_connectivity(test_simulator)

        test_simulator.integrator = HeunDeterministic()
        test_simulator.integrator.clamped_state_variable_indices = numpy.array(
            [1, 2])
        value_for_clamp = numpy.zeros((2, 76, 1))
        test_simulator.integrator.clamped_state_variable_values = value_for_clamp
        test_simulator.integrator.configure()
        test_simulator.configure_integration_for_model()

        test_simulator._configure_history(None)
        assert numpy.array_equal(test_simulator.current_state[1:3, :, :],
                                 value_for_clamp)
コード例 #2
0
ファイル: model_test.py プロジェクト: liadomide/tvb-root
    def _show_model_figure(model_name, model_class, dt, **kwargs):
        # Do some stuff that tests or makes use of this module...
        LOG.info("Testing {} model...".format(model_name))

        # Check that the docstring examples, if there are any, are accurate.
        import doctest
        doctest.testmod()

        # Initialize Models in their default state
        model = model_class(**kwargs)

        LOG.info("Model initialized in its default state without error...")
        LOG.info("Testing phase plane interactive...")

        # Check the Phase Plane
        integrator = HeunDeterministic(dt=dt)
        ppi_fig = PhasePlaneInteractive(model=model, integrator=integrator)
        ppi_fig.show()
コード例 #3
0
    def test_history_bound_and_clamp_only_bound(self):
        from .models_test import TestBoundsModel
        test_simulator = simulator.Simulator()
        test_simulator.model = TestBoundsModel()
        test_simulator.model.configure()
        test_simulator.integrator = HeunDeterministic()
        test_simulator.integrator.configure()
        self._config_connectivity(test_simulator)

        test_simulator._configure_history(None)
        assert numpy.all(
            test_simulator.integrator.bounded_state_variable_indices is None)

        test_simulator.configure_integration_for_model()
        test_simulator._configure_history(None)
        assert numpy.all(
            test_simulator.integrator.bounded_state_variable_indices ==
            numpy.array([0, 1, 2, 3]))
        self._assert_history_inside_boundaries(test_simulator)
コード例 #4
0
 def test_integrator_boundaries_config(self):
     from .models_test import TestBoundsModel
     test_simulator = simulator.Simulator()
     test_simulator.model = TestBoundsModel()
     test_simulator.model.configure()
     test_simulator.integrator = HeunDeterministic()
     test_simulator.integrator.configure()
     test_simulator.configure_integration_for_model()
     assert numpy.all(
         test_simulator.integrator.bounded_state_variable_indices ==
         numpy.array([0, 1, 2, 3]))
     min_float = numpy.finfo("double").min
     max_float = numpy.finfo("double").max
     state_variable_boundaries = numpy.array([[0.0, 1.0], [min_float, 1.0],
                                              [0.0, max_float],
                                              [min_float, max_float]
                                              ]).astype("float64")
     assert numpy.allclose(
         state_variable_boundaries,
         test_simulator.integrator.state_variable_boundaries,
         1.0 / numpy.finfo("single").max)
コード例 #5
0
ファイル: benchmark.py プロジェクト: yop0/tvb-root
 def run(self, project_id):
     for model_kw in self.model_kws:
         for conn in self.connectivities:
             for length in self.sim_lengths:
                 for dt in self.int_dts:
                     for conduction in self.conductions:
                         launch_args = model_kw.copy()
                         launch_args.update({
                             "connectivity":
                             conn,
                             "simulation_length":
                             length,
                             "integrator":
                             HeunDeterministic(dt=dt),
                             "conduction_speed":
                             conduction,
                         })
                         operation = _fire_simulation(
                             project_id, **launch_args)
                         self.running_times.append(
                             operation.completion_date -
                             operation.start_date)
コード例 #6
0
 def test_heun_stochastic(self):
     self._test_integrator(HeunDeterministic())