11"""PEtab import with AMICI simulator."""
22
3+ from __future__ import annotations
4+
35import copy
46import logging
57import os
1820except ImportError :
1921 petab = C = None
2022 logger .error (
21- 'Install PEtab (see https://github.com/icb-dcm/petab) to use '
23+ 'Install the PEtab library '
24+ '(see https://github.com/PEtab-dev/libpetab-python/) to use '
2225 'the petab functionality, e.g. via `pip install pyabc[petab]`'
2326 )
2427
2528try :
2629 import amici
27- from amici .petab import petab_import as amici_petab_import
28- from amici .petab .simulations import LLH , RDATAS , simulate_petab
30+ import amici .sim .sundials as asd
31+ from amici .importers .petab .v1 import import_petab_problem
32+ from amici .sim .sundials .petab .v1 import LLH , RDATAS , simulate_petab
2933except ImportError :
30- amici = amici_petab_import = simulate_petab = LLH = RDATAS = None
34+ amici = import_petab_problem = simulate_petab = LLH = RDATAS = None
3135 logger .error (
32- 'Install amici (see https://github.com/icb-dcm/amici ) to use '
36+ 'Install amici (see https://github.com/AMICI-dev/AMICI/ ) to use '
3337 'the amici functionality, e.g. via `pip install pyabc[amici]`'
3438 )
3539
@@ -113,7 +117,7 @@ def __getstate__(self) -> dict:
113117 try :
114118 # write amici solver settings to file
115119 try :
116- amici . writeSolverSettingsToHDF5 (self .amici_solver , _file )
120+ asd . write_solver_settings_to_hdf5 (self .amici_solver , _file )
117121 except AttributeError as e :
118122 e .args += (
119123 'Pickling the AmiciObjective requires an AMICI '
@@ -133,8 +137,8 @@ def __getstate__(self) -> dict:
133137 def __setstate__ (self , state : dict ):
134138 self .__dict__ .update (state )
135139
136- model = amici_petab_import . import_petab_problem (self .petab_problem )
137- solver = model .getSolver ()
140+ model = import_petab_problem (self .petab_problem )
141+ solver = model .create_solver ()
138142
139143 _fd , _file = tempfile .mkstemp ()
140144 try :
@@ -143,7 +147,7 @@ def __setstate__(self, state: dict):
143147 f .write (state ['amici_solver_settings' ])
144148 # read in solver settings
145149 try :
146- amici . readSolverSettingsFromHDF5 (_file , solver )
150+ asd . read_solver_settings_from_hdf5 (_file , solver )
147151 except AttributeError as err :
148152 if not err .args :
149153 err .args = ('' ,)
@@ -173,28 +177,26 @@ class AmiciPetabImporter(PetabImporter):
173177 amici_model:
174178 A corresponding compiled AMICI model that allows simulating data for
175179 parameters. If not provided, one is created using
176- `amici.petab_import .import_petab_problem`.
180+ `amici.importers.petab.v1 .import_petab_problem`.
177181 amici_solver:
178182 An AMICI solver to simulate the model. If not provided, one is created
179- using `amici_model.getSolver ()`.
183+ using `amici_model.create_solver ()`.
180184 """
181185
182186 def __init__ (
183187 self ,
184188 petab_problem : petab .Problem ,
185- amici_model : ' amici.Model' = None ,
186- amici_solver : ' amici.Solver' = None ,
189+ amici_model : amici .sim . sundials . Model = None ,
190+ amici_solver : amici .sim . sundials . Solver = None ,
187191 ):
188192 super ().__init__ (petab_problem = petab_problem )
189193
190194 if amici_model is None :
191- amici_model = amici_petab_import .import_petab_problem (
192- petab_problem
193- )
195+ amici_model = import_petab_problem (petab_problem )
194196 self .amici_model = amici_model
195197
196198 if amici_solver is None :
197- amici_solver = self .amici_model .getSolver ()
199+ amici_solver = self .amici_model .create_solver ()
198200 self .amici_solver = amici_solver
199201
200202 def create_model (
@@ -214,8 +216,8 @@ def create_model(
214216 Whether to return the simulations also (large, can be stored
215217 in database).
216218 return_rdatas:
217- Whether to return the full `List [amici.ExpData]` objects (large,
218- cannot be stored in database).
219+ Whether to return the full `list [amici.sim.sundials. ExpData]`
220+ objects (large, cannot be stored in database).
219221
220222 Returns
221223 -------
@@ -237,7 +239,7 @@ def create_model(
237239 raise AssertionError ('Parameter id mismatch' )
238240
239241 # no gradients for pyabc
240- self .amici_solver .setSensitivityOrder ( 0 )
242+ self .amici_solver .set_sensitivity_order ( asd . SensitivityOrder . none )
241243
242244 model = AmiciModel (
243245 petab_problem = self .petab_problem ,
0 commit comments