Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ See also our [versioning policy](https://amici.readthedocs.io/en/latest/versioni

## v1.X Series

### v1.0.0 (unreleased)
### v1.0.1

**Fixes**

* Fixed an issue that resulted in failure to import the `PetabImporter` if
the jax-dependencies weren't installed.


### v1.0.0

**BREAKING CHANGES**

Expand Down Expand Up @@ -39,7 +47,7 @@ The following functionality has been removed without replacement:
fixed parameters as "fixed parameters", "constant parameters",
or "constants". This has now been harmonized to "free" and "fixed" across the
API. E.g., `Model.setParameters()` is now `Model.set_free_parameters()`.
* `ReturnDataView.posteq_numsteps` and `ReturnDataView.posteq_numsteps` now
* `ReturnDataView.posteq_numsteps` and `ReturnDataView.preeq_numsteps` now
return a one-dimensional array of shape `(num_timepoints,)` instead of a
two-dimensional array of shape `(1, num_timepoints)`.
* `ReturnDataView.posteq_status` and `ReturnDataView.preeq_status` now
Expand Down
8 changes: 1 addition & 7 deletions python/sdist/amici/importers/petab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,4 @@
passing a :class:`petab.v1.Problem` instance to the PEtab v2 import functions.
"""

# FIXME: for some tests (petab-sciml, maybe petab-v1-pysb) we still rely on an
# old PEtab version on which the petab v2 import does not work.
# Once those tests are updated, we can remove this try-except block.
try:
from ._petab_importer import * # noqa: F403, F401
except ImportError:
pass
from ._petab_importer import * # noqa: F403, F401
6 changes: 4 additions & 2 deletions python/sdist/amici/importers/petab/_petab_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from amici._symbolic import DEModel, Event
from amici.importers.utils import MeasurementChannel, amici_time_symbol
from amici.logging import get_logger
from amici.sim.jax.petab import JAXProblem

from .v1._sbml_import import _add_global_parameter

Expand Down Expand Up @@ -594,7 +593,7 @@ def create_model(self) -> amici.sim.sundials.Model:

def create_simulator(
self, force_import: bool = False
) -> amici.sim.sundials.petab.PetabSimulator:
) -> amici.sim.sundials.petab.PetabSimulator | amici.sim.jax.JAXProblem:
"""
Create a PEtab simulator for the imported model.

Expand All @@ -607,6 +606,9 @@ def create_simulator(
if self._jax:
model_module = self.import_module(force_import=force_import)
model = model_module.Model()

from amici.sim.jax.petab import JAXProblem

return JAXProblem(model, self.petab_problem)

model = self.import_module(force_import=force_import).get_model()
Expand Down
7 changes: 6 additions & 1 deletion python/sdist/amici/sim/jax/petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import diffrax
import equinox as eqx
import h5py
import jax.lax
import jax.numpy as jnp
import jaxtyping as jt
Expand Down Expand Up @@ -593,6 +592,9 @@ def _load_parameter_arrays_from_files(self) -> dict:
"array_files", []
)

import h5py

# TODO(performance): Avoid opening each file multiple times
return {
file_spec.split("_")[0]: h5py.File(file_spec, "r")["parameters"][
file_spec.split("_")[0]
Expand All @@ -615,6 +617,9 @@ def _load_input_arrays_from_files(self) -> dict:
"array_files", []
)

import h5py

# TODO(performance): Avoid opening each file multiple times
return {
file_spec.split("_")[0]: h5py.File(file_spec, "r")["inputs"]
for file_spec in array_files
Expand Down
Loading