Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if ASA is used in combination with events #2097

Merged
merged 3 commits into from
May 26, 2023
Merged
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions python/sdist/amici/swig_wrappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Convenience wrappers for the swig interface"""
import logging
import sys

import warnings
from contextlib import contextmanager, suppress
from typing import Any, Dict, List, Optional, Sequence, Union

Expand Down Expand Up @@ -102,6 +104,18 @@ def runAmiciSimulation(
:returns:
ReturnData object with simulation results
"""
if (
model.ne > 0
and solver.getSensitivityMethod()
== amici_swig.SensitivityMethod.adjoint
and solver.getSensitivityOrder() == amici_swig.SensitivityOrder.first
):
warnings.warn(
"Adjoint sensitivity analysis for models with events with parameter-dependent trigger functions has not been thoroughly tested. "
dweindl marked this conversation as resolved.
Show resolved Hide resolved
"Sensitivities might be wrong. Tracked at https://github.com/AMICI-dev/AMICI/issues/18. "
"If your model does not have parameter-dependent trigger functions, you can safely ignore this message."
dweindl marked this conversation as resolved.
Show resolved Hide resolved
)

with _capture_cstdout():
rdata = amici_swig.runAmiciSimulation(
_get_ptr(solver), _get_ptr(edata), _get_ptr(model)
Expand Down Expand Up @@ -152,6 +166,18 @@ def runAmiciSimulations(

:returns: list of simulation results
"""
if (
model.ne > 0
and solver.getSensitivityMethod()
== amici_swig.SensitivityMethod.adjoint
and solver.getSensitivityOrder() == amici_swig.SensitivityOrder.first
):
warnings.warn(
"Adjoint sensitivity analysis for models with events with parameter-dependent trigger functions has not been thoroughly tested. "
dweindl marked this conversation as resolved.
Show resolved Hide resolved
"Sensitivities might be wrong. Tracked at https://github.com/AMICI-dev/AMICI/issues/18. "
"If your model does not have parameter-dependent trigger functions, you can safely ignore this message."
dweindl marked this conversation as resolved.
Show resolved Hide resolved
)

with _capture_cstdout():
edata_ptr_vector = amici_swig.ExpDataPtrVector(edata_list)
rdata_ptr_list = amici_swig.runAmiciSimulations(
Expand Down