Skip to content

Commit

Permalink
Merge branch 'develop' into test_numpy2
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored May 6, 2024
2 parents cae9876 + 8c3b59a commit 38edece
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 30 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch", "version-update:semver-minor"]
20 changes: 11 additions & 9 deletions python/sdist/amici/de_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,16 +1561,18 @@ def _compute_equation(self, name: str) -> None:
self._eqs[name] = smart_jacobian(self.eq("root"), time_symbol)

elif name == "drootdt_total":
# backsubstitution of optimized right-hand side terms into RHS
# calling subs() is costly. Due to looping over events though, the
# following lines are only evaluated if a model has events
w_sorted = toposort_symbols(
dict(zip(self.sym("w"), self.eq("w"), strict=True))
)
tmp_xdot = smart_subs_dict(self.eq("xdot"), w_sorted)
self._eqs[name] = self.eq("drootdt")
if self.num_states_solver():
self._eqs[name] += smart_multiply(self.eq("drootdx"), tmp_xdot)
# backsubstitution of optimized right-hand side terms into RHS
# calling subs() is costly. We can skip it if we don't have any
# state-dependent roots.
if self.num_states_solver() and not smart_is_zero_matrix(
drootdx := self.eq("drootdx")
):
w_sorted = toposort_symbols(
dict(zip(self.sym("w"), self.eq("w"), strict=True))
)
tmp_xdot = smart_subs_dict(self.eq("xdot"), w_sorted)
self._eqs[name] += smart_multiply(drootdx, tmp_xdot)

elif name == "deltax":
# fill boluses for Heaviside functions, as empty state updates
Expand Down
3 changes: 2 additions & 1 deletion python/sdist/amici/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def get_logger(
elif kwargs:
warnings.warn(
"AMICI logger already exists, ignoring keyword "
"arguments to setup_logger"
"arguments to setup_logger",
stacklevel=2,
)

logger = logging.getLogger(logger_name)
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/parameter_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
warnings.warn(
"Importing amici.parameter_mapping is deprecated. Use `amici.petab.parameter_mapping` instead.",
DeprecationWarning,
stacklevel=2,
)

__all__ = [
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/petab/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def fill_in_parameters(
"The following problem parameters were not used: "
+ str(unused_parameters),
RuntimeWarning,
stacklevel=2,
)

for edata, mapping_for_condition in zip(
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/petab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
warnings.warn(
"Importing amici.petab_import is deprecated. Use `amici.petab` instead.",
DeprecationWarning,
stacklevel=2,
)

from .petab.import_helpers import ( # noqa # pylint: disable=unused-import
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/petab_import_pysb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
warnings.warn(
"Importing amici.petab_import_pysb is deprecated. Use `amici.petab.pysb_import` instead.",
DeprecationWarning,
stacklevel=2,
)

__all__ = [
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/petab_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
warnings.warn(
f"Importing {__name__} is deprecated. Use `amici.petab.simulations` instead.",
DeprecationWarning,
stacklevel=2,
)

from .petab.conditions import fill_in_parameters # noqa: F401
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/petab_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
warnings.warn(
f"Importing {__name__} is deprecated. Use `amici.petab.simulator` instead.",
DeprecationWarning,
stacklevel=2,
)

from .petab.simulator import PetabSimulator # noqa: F401
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/petab_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
warnings.warn(
f"Importing {__name__} is deprecated. Use `amici.petab.util` instead.",
DeprecationWarning,
stacklevel=2,
)

__all__ = [
Expand Down
18 changes: 12 additions & 6 deletions python/sdist/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ def sbml2amici(
if not has_clibs:
warnings.warn(
"AMICI C++ extensions have not been built. "
"Generated model code, but unable to compile."
"Generated model code, but unable to compile.",
stacklevel=2,
)
exporter.compile_model()

Expand Down Expand Up @@ -1838,7 +1839,8 @@ def _process_event_observables(
f'Event observable {eo["name"]} uses `t` in '
"it's formula which is not the time variable. "
"For the time variable, please use `time` "
"instead!"
"instead!",
stacklevel=1,
)

# check for nesting of observables (unsupported)
Expand Down Expand Up @@ -2157,7 +2159,8 @@ def _get_conservation_laws_demartino(
"Conservation laws for non-constant species in "
"combination with parameterized stoichiometric "
"coefficients are not currently supported "
"and will be turned off."
"and will be turned off.",
stacklevel=1,
)
return []

Expand Down Expand Up @@ -2234,7 +2237,8 @@ def _get_conservation_laws_rref(
"Conservation laws for non-constant species in "
"combination with parameterized stoichiometric "
"coefficients are not currently supported "
"and will be turned off."
"and will be turned off.",
stacklevel=1,
)
return []

Expand Down Expand Up @@ -3048,7 +3052,8 @@ def _non_const_conservation_laws_supported(sbml_model: sbml.Model) -> bool:
warnings.warn(
"Conservation laws for non-constant species in "
"models with RateRules are currently not supported "
"and will be turned off."
"and will be turned off.",
stacklevel=1,
)
return False

Expand All @@ -3060,7 +3065,8 @@ def _non_const_conservation_laws_supported(sbml_model: sbml.Model) -> bool:
warnings.warn(
"Conservation laws for non-constant species in "
"models with Species-AssignmentRules are currently not "
"supported and will be turned off."
"supported and will be turned off.",
stacklevel=1,
)
return False

Expand Down
6 changes: 4 additions & 2 deletions python/sdist/amici/swig_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def runAmiciSimulation(
warnings.warn(
"Adjoint sensitivity analysis for models with discontinuous right hand sides (events/piecewise functions) has not been thoroughly tested."
"Sensitivities might be wrong. Tracked at https://github.com/AMICI-dev/AMICI/issues/18. "
"Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients."
"Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients.",
stacklevel=1,
)

with _capture_cstdout():
Expand Down Expand Up @@ -119,7 +120,8 @@ def runAmiciSimulations(
warnings.warn(
"Adjoint sensitivity analysis for models with discontinuous right hand sides (events/piecewise functions) has not been thoroughly tested. "
"Sensitivities might be wrong. Tracked at https://github.com/AMICI-dev/AMICI/issues/18. "
"Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients."
"Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients.",
stacklevel=1,
)

with _capture_cstdout():
Expand Down
1 change: 1 addition & 0 deletions python/sdist/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ line-length = 79
extend-include = ["*.ipynb"]

[tool.ruff.lint]
extend-select = ["B028"]
ignore = ["E402", "F403", "F405", "E741"]
13 changes: 4 additions & 9 deletions python/tests/splines_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import math
import os
import platform
import uuid
from tempfile import mkdtemp
from typing import Any
Expand Down Expand Up @@ -716,13 +717,7 @@ def param_by_name(id):
if sllh_atol is None:
sllh_atol = np.finfo(float).eps
sllh_err_abs = abs(sllh).max()
if (
sllh_err_abs > sllh_atol and debug is not True
) or debug == "print":
print(f"sllh_atol={sllh_atol}")
print(f"sllh_err_abs = {sllh_err_abs}")
if not debug:
assert sllh_err_abs <= sllh_atol
assert sllh_err_abs <= sllh_atol, f"{sllh_err_abs=} {sllh_atol=}"
else:
assert sllh is None

Expand Down Expand Up @@ -917,11 +912,11 @@ def example_spline_1(
extrapolate=extrapolate,
)

if os.name == "nt":
if os.name == "nt" or platform.system() == "Darwin":
tols = (
dict(llh_rtol=1e-15, x_rtol=1e-8, x_atol=1e-7),
dict(llh_rtol=1e-15, x_rtol=1e-8, x_atol=1e-7),
dict(llh_rtol=1e-15, sllh_atol=5e-8, x_rtol=1e-8, x_atol=1e-7),
dict(llh_rtol=1e-15, sllh_atol=5e-7, x_rtol=1e-8, x_atol=1e-7),
)
else:
tols = (
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def test_constraints():
# in practice
assert np.any(rdata.x < 0)

amici_solver.setRelativeTolerance(1e-14)
amici_solver.setRelativeTolerance(1e-13)
amici_solver.setConstraints(
[Constraint.non_negative, Constraint.non_negative]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/cpp/steadystate/tests1.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "testfunctions.h"

#include "wrapfunctions.h"
#include <cstring>

#include <gtest/gtest.h>

Expand Down Expand Up @@ -175,7 +174,8 @@ TEST(ExampleSteadystate, SensitivityForwardErrorNewt)

TEST(ExampleSteadystate, SensitivityForwardDense)
{
amici::simulateVerifyWrite("/model_steadystate/sensiforwarddense/");
amici::simulateVerifyWrite("/model_steadystate/sensiforwarddense/",
1e-9, TEST_RTOL);
}

TEST(ExampleSteadystate, SensiFwdNewtonPreeq)
Expand Down

0 comments on commit 38edece

Please sign in to comment.