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

Handling of simulation failures in AmiciPredictor #1359

Open
dweindl opened this issue Apr 4, 2024 · 0 comments
Open

Handling of simulation failures in AmiciPredictor #1359

dweindl opened this issue Apr 4, 2024 · 0 comments
Labels
AMICI ensembles Related to parameter ensembles

Comments

@dweindl
Copy link
Member

dweindl commented Apr 4, 2024

Currently, when AmiciPredictor processes a failed simulation, it sets the timepoints to NaN:

amici_output[AMICI_T]
if amici_output[AMICI_STATUS] == 0
else np.full((amici_nt[i_condition],), np.nan)

This is rather inconvenient, since those NaNs cause issues in pypesto.visualize.sampling.sampling_prediction_trajectories later on:

File /venv/lib/python3.11/site-packages/pypesto/visualize/sampling.py:901, in sampling_prediction_trajectories(ensemble_prediction, levels, title, size, axes, labels, axis_label_padding, groupby, condition_gap, condition_ids, output_ids, weighting, reverse_opacities, average, add_sd, measurement_df)
    887     _plot_trajectories_by_condition(
    888         summary=summary,
    889         condition_ids=condition_ids,
   (...)
    898         grouped_measurements=grouped_measurements,
    899     )
    900 elif groupby == OUTPUT:
--> 901     _plot_trajectories_by_output(
    902         summary=summary,
    903         condition_ids=condition_ids,
    904         output_ids=output_ids,
    905         axes=axes,
    906         levels=levels,
    907         level_opacities=level_opacities,
    908         labels=labels,
    909         variable_colors=variable_colors,
    910         average=average,
    911         add_sd=add_sd,
    912         grouped_measurements=grouped_measurements,
    913     )
    915 if title:
    916     fig.suptitle(title)

File /venv/lib/python3.11/site-packages/pypesto/visualize/sampling.py:435, in _plot_trajectories_by_output(summary, condition_ids, output_ids, axes, levels, level_opacities, labels, variable_colors, average, add_sd, grouped_measurements)
    432 # Timepoints must match, or `upper_data` will be plotted at
    433 # some incorrect time points.
    434 if not (np.array(t_lower) == np.array(t_upper)).all():
--> 435     raise ValueError(
    436         "The timepoints of the data for the upper and lower "
    437         "percentiles do not match."
    438     )
    439 # Plot a shaded region between the data that correspond to the
    440 # lower and upper percentiles.
    441 ax.fill_between(
    442     t_lower_shifted,
    443     lower_data,
   (...)
    448     lw=0,
    449 )

ValueError: The timepoints of the data for the upper and lower percentiles do not match.  

I see no harm in using the actual timepoints instead of NaNs in the case of failed simulations and would suggest doing that.

@dweindl dweindl added the ensembles Related to parameter ensembles label Apr 4, 2024
@dweindl dweindl added the AMICI label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AMICI ensembles Related to parameter ensembles
Projects
None yet
Development

No branches or pull requests

1 participant