Skip to content

Commit b2fdbec

Browse files
committed
skip some more tests and reinstate more specific implicit triggers check
1 parent eee4dd3 commit b2fdbec

6 files changed

Lines changed: 38 additions & 21 deletions

File tree

.github/workflows/test_petab_test_suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ jobs:
186186
run: |
187187
source ./venv/bin/activate \
188188
&& python3 -m pip uninstall -y petab \
189-
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@8dc6c1c4b801fba5acc35fcd25308a659d01050e \
189+
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@d57d9fed8d8d5f8592e76d0b15676e05397c3b4b \
190190
&& python3 -m pip install git+https://github.com/pysb/pysb@master \
191191
&& python3 -m pip install sympy>=1.12.1
192192

python/sdist/amici/_symbolic/de_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2724,7 +2724,7 @@ def has_implicit_event_assignments(self) -> bool:
27242724
:return:
27252725
boolean indicating if event assignments with implicit triggers are present
27262726
"""
2727-
return any(event.updates_state and not event.has_explicit_trigger_times({}) for event in self._events)
2727+
return any(event.updates_state and event._implicit_symbols() for event in self._events)
27282728

27292729
def toposort_expressions(
27302730
self, reorder: bool = True

python/sdist/amici/_symbolic/de_model_components.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,15 @@ def get_trigger_times(self) -> set[sp.Expr]:
875875
time points at which the event triggers.
876876
"""
877877
return set(self._t_root)
878+
879+
def _implicit_symbols(self):
880+
symbols = [str(s) for s in list(self.get_val().free_symbols)]
881+
implicit_symbols = []
882+
for s in symbols:
883+
if (s.startswith("_petab_") and "indicator" in s) or s == "t":
884+
continue
885+
implicit_symbols.append(s)
886+
return len(implicit_symbols) > 0
878887

879888
@property
880889
def uses_values_from_trigger_time(self) -> bool:

python/sdist/amici/jax/ode_export.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ def __init__(
161161
"The JAX backend does not support simultaneous events because event priorities are not supported."
162162
)
163163

164-
# if ode_model.has_implicit_event_assignments():
165-
# raise NotImplementedError(
166-
# "The JAX backend does not support event assignments with implicit triggers."
167-
# )
164+
if ode_model.has_implicit_event_assignments():
165+
raise NotImplementedError(
166+
"The JAX backend does not support event assignments with implicit triggers."
167+
)
168168

169169
self.verbose: bool = logger.getEffectiveLevel() <= logging.DEBUG
170170

python/tests/test_jax.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -284,21 +284,27 @@ def check_fields_jax(
284284
def test_preequilibration_failure(lotka_volterra): # noqa: F811
285285
petab_problem = lotka_volterra
286286
# oscillating system, preequilibation should fail when interaction is active
287-
with TemporaryDirectoryWinSafe(prefix="normal") as model_dir:
288-
jax_problem = import_petab_problem(
289-
petab_problem, jax=True, output_dir=model_dir
290-
)
291-
r = run_simulations(jax_problem)
292-
assert not np.isinf(r[0].item())
293-
petab_problem.measurement_df[PREEQUILIBRATION_CONDITION_ID] = (
294-
petab_problem.measurement_df[SIMULATION_CONDITION_ID]
295-
)
296-
with TemporaryDirectoryWinSafe(prefix="failure") as model_dir:
297-
jax_problem = import_petab_problem(
298-
petab_problem, jax=True, output_dir=model_dir
287+
288+
try:
289+
with TemporaryDirectoryWinSafe(prefix="normal") as model_dir:
290+
jax_problem = import_petab_problem(
291+
petab_problem, jax=True, output_dir=model_dir
292+
)
293+
r = run_simulations(jax_problem)
294+
assert not np.isinf(r[0].item())
295+
petab_problem.measurement_df[PREEQUILIBRATION_CONDITION_ID] = (
296+
petab_problem.measurement_df[SIMULATION_CONDITION_ID]
299297
)
300-
r = run_simulations(jax_problem)
301-
assert np.isinf(r[0].item())
298+
with TemporaryDirectoryWinSafe(prefix="failure") as model_dir:
299+
jax_problem = import_petab_problem(
300+
petab_problem, jax=True, output_dir=model_dir
301+
)
302+
r = run_simulations(jax_problem)
303+
assert np.isinf(r[0].item())
304+
except (TypeError, NotImplementedError) as err:
305+
if "run_simulations does not support PEtab v1 problems" in str(err):
306+
pytest.skip(str(err))
307+
raise err
302308

303309

304310
@skip_on_valgrind

tests/benchmark_models/test_petab_benchmark_jax.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ def test_jax_llh(benchmark_problem):
151151
atol=1e-2,
152152
err_msg=f"SLLH mismatch for {problem_id}, {dict(zip(jax_problem.parameter_ids, sllh_jax.parameters))}",
153153
)
154-
except TypeError as err:
154+
except (NotImplementedError, TypeError) as err:
155155
if "run_simulations does not support PEtab v1 problems" in str(err):
156156
pytest.skip(str(err))
157+
if "The JAX backend does not support simultaneous events" in str(err):
158+
pytest.skip(str(err))
157159
raise err

0 commit comments

Comments
 (0)