Skip to content

MMMPlotSuite.sensitivity_analysis relies on monkey-patched idata group #2377

@isofer

Description

@isofer

Problem

MMMPlotSuite.sensitivity_analysis() appears self-contained (no external data argument), but at runtime it reads from self.idata.sensitivity_analysis -- a group that doesn't exist after fitting. It's injected by a separate SensitivityAnalysis.run_sweep(..., extend_idata=True) call.

This means:

  • The method looks like it should work out of the box (like residuals_over_time() or saturation_scatterplot()), but silently depends on a prior side-effect.
  • The dependency is invisible in the method signature -- there's no parameter hinting that external data is needed.
  • The error message ("No sensitivity analysis results found. Call .sensitivity.run_sweep() first.") is helpful, but the design itself is fragile: it relies on dynamically attaching a group to idata via hasattr checking.

Recommendation

Make the data dependency explicit by accepting the sensitivity analysis results as a parameter (e.g., sensitivity_analysis(data: xr.Dataset | xr.DataArray)), consistent with how budget_allocation(samples=...), cv_predictions(results=...), and saturation_curves(curve=...) handle external data. Keep the current fallback to self.idata.sensitivity_analysis for backwards compatibility if desired.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions