How to use the amici.getEdataFromDataFrame 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 / testSBML.py View on Github external
def steadystate_simulation(self, model_module):
        def assert_fun(x):
            return self.assertTrue(x)

        model = model_module.getModel()
        model.setTimepoints(np.linspace(0, 60, 60))
        solver = model.getSolver()
        solver.setSensitivityOrder(amici.SensitivityOrder_first)
        rdata = amici.runAmiciSimulation(model, solver)
        edata = [amici.ExpData(rdata, 1, 0)]
        rdata = amici.runAmiciSimulations(model, solver, edata)

        # check roundtripping of DataFrame conversion
        df_edata = amici.getDataObservablesAsDataFrame(model, edata)
        edata_reconstructed = amici.getEdataFromDataFrame(model, df_edata)

        self.assertTrue(
            np.isclose(
                amici.ExpDataView(edata[0])
                ['observedData'],
                amici.ExpDataView(edata_reconstructed[0])
                ['observedData'],
            ).all()
        )
        self.assertTrue(
            np.isclose(
                amici.ExpDataView(edata[0])
                ['observedDataStdDev'],
                amici.ExpDataView(edata_reconstructed[0])
                ['observedDataStdDev'],
            ).all()
github ICB-DCM / AMICI / tests / testPandas.py View on Github external
cases[f'{icombo}'] = {
                'fixedParameters': combo[0],
                'fixedParametersPreequilibration': combo[1],
                'fixedParametersPresimulation': combo[2],
            }

        for case in cases:
            with self.subTest(**cases[case]):
                for fp in cases[case]:
                    setattr(self.edata[0], fp, cases[case][fp])

                df_edata = amici.getDataObservablesAsDataFrame(
                    self.model,
                    self.edata
                )
                edata_reconstructed = amici.getEdataFromDataFrame(
                    self.model,
                    df_edata
                )

                for fp in ['fixedParameters', 'fixedParametersPreequilibration',
                           'fixedParametersPresimulation']:

                    if fp != 'fixedParameters' or cases[case][fp] is not ():
                        self.assertTupleEqual(
                            getattr(self.edata[0], fp),
                            getattr(edata_reconstructed[0], fp),
                        )

                        self.assertTupleEqual(
                            cases[case][fp],
                            getattr(edata_reconstructed[0], fp),