How to use the amici.amici.ExpData function in amici

To help you get started, we’ve selected a few amici examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ICB-DCM / AMICI / tests / testModels.py View on Github external
verify_simulation_opts['atol'] = 1e-5
                        verify_simulation_opts['rtol'] = 1e-2
          
                    if model_name.startswith('model_robertson') and \
                            case == 'sensiforwardSPBCG':
                        verify_simulation_opts['atol'] = 1e-3
                        verify_simulation_opts['rtol'] = 1e-3
                  
                    verify_simulation_results(
                        rdata, expected_results[subTest][case]['results'],
                        assert_fun, **verify_simulation_opts
                    )

                    if model_name == 'model_steadystate' and \
                            case == 'sensiforwarderrorint':
                        edata = amici.amici.ExpData(self.model.get())

                    if edata and model_name != 'model_neuron_o2' and not (
                        model_name == 'model_robertson' and
                        case == 'sensiforwardSPBCG'
                    ):
                        # Test runAmiciSimulations: ensure running twice
                        # with same ExpData yields same results
                        if isinstance(edata, amici.amici.ExpData):
                            edatas = [edata, edata]
                        else:
                            edatas = [edata.get(), edata.get()]

                        rdatas = amici.runAmiciSimulations(
                            self.model, self.solver, edatas, num_threads=2,
                            failfast=False
                        )
github ICB-DCM / pyPESTO / pypesto / objective / amici.py View on Github external
pickling, required in some parallelization schemes.
        calculator:
            Performs the actual calculation of the function values and
            derivatives.
        """
        if amici is None:
            raise ImportError(
                "This objective requires an installation of amici "
                "(https://github.com/icb-dcm/amici). "
                "Install via `pip3 install amici`.")

        self.amici_model = amici.ModelPtr(amici_model.clone())
        self.amici_solver = amici.SolverPtr(amici_solver.clone())

        # make sure the edatas are a list of edata objects
        if isinstance(edatas, amici.amici.ExpData):
            edatas = [edatas]

        # set the experimental data container
        self.edatas = edatas

        # set the maximum sensitivity order
        self.max_sensi_order = max_sensi_order

        self.guess_steadystate = guess_steadystate

        # optimization parameter ids
        if x_ids is None:
            # use model parameter ids as ids
            x_ids = list(self.amici_model.getParameterIds())
        self.x_ids = x_ids
github ICB-DCM / AMICI / python / amici / pandas.py View on Github external
model: Model instance.
        edata_list: list of ExpData instances with experimental data.
            May also be a single ExpData instance.
        rdata_list: list of ReturnData instances corresponding to ExpData.
            May also be a single ReturnData instance.
        by_id: bool, optional (default = False)
            If True, ids are used as identifiers, otherwise the possibly more
            descriptive names.

    Returns:
        pandas DataFrame with conditions and observables.

    Raises:

    """
    if isinstance(edata_list, (amici.amici.ExpData, amici.amici.ExpDataPtr)):
        edata_list = [edata_list]
    if isinstance(rdata_list, (amici.amici.ReturnData, amici.amici.ReturnDataPtr)):
        rdata_list = [rdata_list]

    # get conditions and state column names by name or id
    cols = _get_state_cols(model, by_id=by_id)

    # initialize dataframe with columns
    df_rdata = pd.DataFrame(columns=cols)

    # append states
    for edata, rdata in zip(edata_list, rdata_list):
        for i_time, timepoint in enumerate(rdata['t']):
            datadict = {
                'time': timepoint,
            }