Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3115 +/- ##
==========================================
- Coverage 78.24% 77.32% -0.92%
==========================================
Files 315 316 +1
Lines 20482 20648 +166
Branches 1484 1483 -1
==========================================
- Hits 16027 15967 -60
- Misses 4447 4673 +226
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
b2fdbec to
9d107b3
Compare
|
|
Sorry for the delay, I'll try to review tomorrow or the day after. |
dweindl
left a comment
There was a problem hiding this comment.
Cool, thanks. Here some initial comments. Didn't manage to go over everything yet.
| if (s.startswith("_petab_") and "indicator" in s) or s == "t": | ||
| continue | ||
| implicit_symbols.append(s) | ||
| return len(implicit_symbols) > 0 |
There was a problem hiding this comment.
This sub-package should stay PEtab-independent. I think a better way to handle that would be passing all indicator variables as fixed_parameters to SbmlImporter._build_ode_model via SbmlImporter.sbml2jax and then use the same logic as for the non-jax event handling.
python/sdist/amici/jax/petab.py
Outdated
| self._initialize_model_with_nominal_values(model) | ||
| ) | ||
| self._parameter_mappings = self._get_parameter_mappings(scs) | ||
| if isinstance(petab_problem, petabv1.Problem): |
There was a problem hiding this comment.
Merge with the if isinstance above?
python/sdist/amici/jax/petab.py
Outdated
| """ | ||
| scs = petab_problem.get_simulation_conditions_from_measurement_df() | ||
| self.simulation_conditions = tuple(tuple(sc) for sc in scs.values) | ||
| if isinstance(petab_problem, petabv2.Problem): |
There was a problem hiding this comment.
Is the plan to support both, petab v1 and v2, or is this just until petab-sciml is updated?
support explicit initial value event assignments fix deltax tcl
Co-authored-by: Fabian Fröhlich <fabian.frohlich@crick.ac.uk>
This reverts commit 82caa94.
…parameter_mapping
…event assignments with assumed priority
cadaa43 to
8286033
Compare
| ")" | ||
| ], | ||
| "id": "3f2ab1acb3ba818f" | ||
| "amici_model.simulate(petab_problem.get_x_nominal_dict())" |
There was a problem hiding this comment.
When the notebook runs there is an error from this cell that the FIM was not computed: https://github.com/AMICI-dev/AMICI/actions/runs/21985309084/job/63517900881?pr=3115
@dweindl can you advise on that?
| """Check whether the event has implicit triggers. | ||
| """ | ||
| t = self.get_val() | ||
| return not t.free_symbols.issubset(allowed_symbols) |
There was a problem hiding this comment.
I removed the PEtab related references from this function and am passing the indicator variables as fixed_parameters. I wanted to include this logic in the has_explicit_trigger_times function but in all the JAX examples, self._t_root is not set. Should _t_root be set during the import of petab events?
There was a problem hiding this comment.
Oh, okay. I think this might be a general issue, not just with JAX. My guess is that sympy isn't able to solve those petab event trigger piecewise expressions for
AMICI/python/sdist/amici/_symbolic/de_model_components.py
Lines 768 to 772 in 20b07e9
There was a problem hiding this comment.
Indeed, sympy is failing to solve these expressions. Opened #3126
| self.simulation_conditions = tuple(tuple(sc) for sc in scs.values) | ||
| if isinstance(petab_problem, petabv1.Problem): | ||
| raise TypeError( | ||
| "JAXProblem does not support PEtab v1 problems. Upgrade the problem to PEtab v2." |
There was a problem hiding this comment.
The plan is just to support v2, so I've added this error if a v1 problem is encountered.
There was a problem hiding this comment.
Great. Can you please replace all the petab.v1 constants by those in petab.v2 to make it clear that we don't want to deal with v1 here?
It seems there is still quite a bit of v1 code left here. Probably all occurrences of simulationConditionId/SIMULATION_CONDITION_ID. Is that still needed for petab-sciml? If not please remove.
dweindl
left a comment
There was a problem hiding this comment.
Thanks, @BSnelling. Here a few more comments. Okay for me to merge once all tests pass and to address the remaining issues together with the petab-sciml update if that's more convenient.
| petabv1.OBSERVABLE_ID: obs, | ||
| petabv2.C.EXPERIMENT_ID: [experiment_id] * len(t), | ||
| petabv1.TIME: t[problem._ts_masks[ic, :]], | ||
| petabv1.SIMULATION: y[ic, problem._ts_masks[ic, :]], | ||
| }, | ||
| index=problem._petab_measurement_indices[ic, :], | ||
| ) | ||
| if ( | ||
| petabv1.OBSERVABLE_PARAMETERS | ||
| in problem._petab_problem.measurement_df | ||
| ): | ||
| df_sc[petabv2.C.OBSERVABLE_PARAMETERS] = ( | ||
| problem._petab_problem.measurement_df.query( | ||
| f"{petabv2.C.EXPERIMENT_ID} == '{experiment_id}'" | ||
| )[petabv2.C.OBSERVABLE_PARAMETERS] | ||
| ) | ||
| if petabv1.NOISE_PARAMETERS in problem._petab_problem.measurement_df: |
There was a problem hiding this comment.
| petabv1.OBSERVABLE_ID: obs, | |
| petabv2.C.EXPERIMENT_ID: [experiment_id] * len(t), | |
| petabv1.TIME: t[problem._ts_masks[ic, :]], | |
| petabv1.SIMULATION: y[ic, problem._ts_masks[ic, :]], | |
| }, | |
| index=problem._petab_measurement_indices[ic, :], | |
| ) | |
| if ( | |
| petabv1.OBSERVABLE_PARAMETERS | |
| in problem._petab_problem.measurement_df | |
| ): | |
| df_sc[petabv2.C.OBSERVABLE_PARAMETERS] = ( | |
| problem._petab_problem.measurement_df.query( | |
| f"{petabv2.C.EXPERIMENT_ID} == '{experiment_id}'" | |
| )[petabv2.C.OBSERVABLE_PARAMETERS] | |
| ) | |
| if petabv1.NOISE_PARAMETERS in problem._petab_problem.measurement_df: | |
| petabv2.OBSERVABLE_ID: obs, | |
| petabv2.C.EXPERIMENT_ID: [experiment_id] * len(t), | |
| petabv2.TIME: t[problem._ts_masks[ic, :]], | |
| petabv2.SIMULATION: y[ic, problem._ts_masks[ic, :]], | |
| }, | |
| index=problem._petab_measurement_indices[ic, :], | |
| ) | |
| if ( | |
| petabv2.OBSERVABLE_PARAMETERS | |
| in problem._petab_problem.measurement_df | |
| ): | |
| df_sc[petabv2.C.OBSERVABLE_PARAMETERS] = ( | |
| problem._petab_problem.measurement_df.query( | |
| f"{petabv2.C.EXPERIMENT_ID} == '{experiment_id}'" | |
| )[petabv2.C.OBSERVABLE_PARAMETERS] | |
| ) | |
| if petabv2.NOISE_PARAMETERS in problem._petab_problem.measurement_df: |
No effect, but since the function is specifically for petab v2, let's use the constants from there.
| self.simulation_conditions = tuple(tuple(sc) for sc in scs.values) | ||
| if isinstance(petab_problem, petabv1.Problem): | ||
| raise TypeError( | ||
| "JAXProblem does not support PEtab v1 problems. Upgrade the problem to PEtab v2." |
There was a problem hiding this comment.
Great. Can you please replace all the petab.v1 constants by those in petab.v2 to make it clear that we don't want to deal with v1 here?
It seems there is still quite a bit of v1 code left here. Probably all occurrences of simulationConditionId/SIMULATION_CONDITION_ID. Is that still needed for petab-sciml? If not please remove.
| self._petab_problem.observable_df.loc[ | ||
| oid, petab.OBSERVABLE_TRANSFORMATION | ||
| oid, petabv1.OBSERVABLE_TRANSFORMATION | ||
| ] |
There was a problem hiding this comment.
As a general comment: With petab.v2.Problem, all .*_df properties construct a new DataFrame on each call. Try to avoid accessing those properties inside loops.
In many cases it might be more convenient to directly use the underlying objects instead of the DataFrames (e.g., Problem.observables instead of Problem.observable_df).



No description provided.