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
4 changes: 1 addition & 3 deletions python/sdist/amici/importers/pysb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import sys
from collections.abc import Callable, Iterable
from pathlib import Path
from typing import (
Any,
)
from typing import Any

import numpy as np
import pysb
Expand Down
1 change: 0 additions & 1 deletion python/sdist/amici/importers/sbml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@

SymbolicFormula = dict[sp.Symbol, sp.Expr]


default_symbols = {symbol: {} for symbol in SymbolId}

ConservationLaw = dict[str, str | sp.Expr]
Expand Down
10 changes: 4 additions & 6 deletions python/sdist/amici/importers/sbml/conserved_quantities_rref.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""Find conserved quantities deterministically"""

from typing import Literal

import numpy as np

__all__ = ["nullspace_by_rref", "rref"]


def rref(
mat: np.array, round_ndigits: Literal[False] | int | None = None
) -> np.array:
mat: np.ndarray, round_ndigits: bool | int | None = None
) -> np.ndarray:
"""
Bring matrix ``mat`` to reduced row echelon form

Expand Down Expand Up @@ -69,7 +67,7 @@ def _round(mat):
return mat


def pivots(mat: np.array) -> list[int]:
def pivots(mat: np.ndarray) -> list[int]:
"""Get indices of pivot columns in ``mat``, assumed to be in reduced row
echelon form"""
pivot_cols = []
Expand All @@ -83,7 +81,7 @@ def pivots(mat: np.array) -> list[int]:
return pivot_cols


def nullspace_by_rref(mat: np.array) -> np.array:
def nullspace_by_rref(mat: np.ndarray) -> np.ndarray:
"""Compute basis of the nullspace of ``mat`` based on the reduced row
echelon form"""
rref_mat = rref(mat)
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/sim/sundials/_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def __repr__(self):

def by_id(
self, entity_id: str, field: str = None, model: Model = None
) -> np.array:
) -> np.ndarray:
"""
Get the value of a given field for a named entity.

Expand Down Expand Up @@ -635,7 +635,7 @@ def _entity_type_from_id(
raise KeyError(f"Unknown symbol {entity_id}.")


def evaluate(expr: StrOrExpr, rdata: ReturnDataView) -> np.array:
def evaluate(expr: StrOrExpr, rdata: ReturnDataView) -> np.ndarray:
"""Evaluate a symbolic expression based on the given simulation outputs.

:param expr:
Expand Down
12 changes: 8 additions & 4 deletions python/sdist/amici/sim/sundials/gradient_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
ExpData,
Model,
ParameterScaling,
ReturnData,
ReturnDataView,
SensitivityMethod,
SensitivityOrder,
Solver,
Expand Down Expand Up @@ -272,8 +272,8 @@ def check_derivatives(


def _check_close(
result: np.array,
expected: np.array,
result: np.ndarray,
expected: np.ndarray,
atol: float,
rtol: float,
field: str,
Expand Down Expand Up @@ -342,7 +342,11 @@ def _check_close(


def _check_results(
rdata: ReturnData, field: str, expected: np.array, atol: float, rtol: float
rdata: ReturnDataView,
field: str,
expected: np.ndarray,
atol: float,
rtol: float,
) -> None:
"""
Checks whether rdata[field] agrees with expected according to provided
Expand Down
7 changes: 6 additions & 1 deletion python/sdist/amici/sim/sundials/petab/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from ._conditions import create_edatas, create_parameterized_edatas
from ._conditions import (
create_edatas,
create_parameterized_edatas,
fill_in_parameters,
)
from ._petab_problem import PetabProblem
from ._simulations import (
EDATAS,
Expand Down Expand Up @@ -31,4 +35,5 @@
"PetabSimulator",
"create_edatas",
"create_parameterized_edatas",
"fill_in_parameters",
]
2 changes: 2 additions & 0 deletions python/sdist/amici/sim/sundials/petab/v1/_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
"SRES",
"RDATAS",
"EDATAS",
"rdatas_to_measurement_df",
"rdatas_to_simulation_df",
]


Expand Down
7 changes: 6 additions & 1 deletion python/sdist/amici/testing/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Test models used by AMICI."""

from __future__ import annotations

import sys
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING

import libsbml
import sympy as sp
Expand All @@ -11,7 +14,9 @@
from amici.importers.antimony import antimony2amici, antimony2sbml
from amici.importers.sbml.splines import CubicHermiteSpline
from amici.importers.utils import amici_time_symbol
from amici.sim.sundials import AmiciModel, Model

if TYPE_CHECKING:
from amici.sim.sundials import AmiciModel, Model

model_dirac_ant = r"""
p1 = 1;
Expand Down
2 changes: 1 addition & 1 deletion python/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

import numpy as np
import pandas as pd
from amici import import_model_module
from amici.importers.sbml import SbmlImporter
from amici.sim.sundials import (
AMICI_SUCCESS,
AmiciModel,
ExpData,
SensitivityMethod,
SensitivityOrder,
import_model_module,
run_simulation,
)
from amici.sim.sundials.gradient_check import _check_close
Expand Down
Loading