Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
repeat=3
)
cases = dict()
for icombo, combo in enumerate(combos):
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),
)
def test_replicates(self):
"""
Use a model that has replicates and check that all data points are
inserted.
"""
# import a model with replicates at some time points and observables
importer = pypesto.PetabImporter.from_folder(
folder_base + "Schwen_PONE2014")
# create amici.ExpData list
edatas = importer.create_edatas()
# convert to dataframe
amici_df = amici.getDataObservablesAsDataFrame(
importer.create_model(), edatas)
# extract original measurement df
meas_df = importer.petab_problem.measurement_df
# find time points
amici_times = sorted(amici_df.time.unique().tolist())
meas_times = sorted(meas_df.time.unique().tolist())
# assert same time points
for amici_time, meas_time in zip(amici_times, meas_times):
self.assertTrue(np.isclose(amici_time, meas_time))
# extract needed stuff from amici df
amici_df = amici_df[[col for col in amici_df.columns
if col == 'time' or col.startswith('observable_')
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'],