Skip to content

A forward-sensitivity run refused partway arrives as a plain SimulationError, told from a solver failure only by its text #1435

Open

Description

@elyfmiller

#1336 (#1313) gives two of bngsim's refusals by name types of their own. #1411 (#1279) adds a C++ bngsim::SensitivityUnsupported, which the pybind11 layer maps to SensitivityUnsupportedError, for the one refusal it adds.

The rest of the refusals a sensitivity run reaches partway are still untyped. These are runs that CVODE starts and then refuses, because something the forward-sensitivity path can't follow happens during the run, for example:

  • a parameter's column moves an event's crossing;
  • a column moves a counter species;
  • the run restarts;
  • a state-dependent rate-law switch crosses;
  • two events fire on one instant.

src/cvode_simulator.cpp builds 45 such messages, each starting Forward sensitivity:. It throws all 45 as std::runtime_error: 43 where the message is built, and two after keeping it as a reason (L9892). Examples: L6355, L6825, L7207. The count is the same with #1411 merged. run() wraps each one as SimulationError("Simulation failed: …").

A caller that has to tell these refusals from a crash reads the text. The path-agreement harness's _declined counts a SimulationError as a refusal when its message contains "forward sensitivity" or "forward-sensitivity run" (#1229's class). There, a reworded message turns a refusal into a crash, as it did for the two refusals #1313 types.

Fix: throw #1411's SensitivityUnsupported for the 45 messages, once #1411 lands. _declined then needs only its isinstance.

One thing to decide for all 45 at once: SensitivityUnsupportedError subclasses BngsimError and ValueError, not SimulationError. So once these are typed, an except SimulationError around a sensitivity run stops catching them. #1411 made that choice for its one refusal. A subclass of both SimulationError and SensitivityUnsupportedError would keep both except clauses working.

Found in the review of #1336 (its low 5).

Activity

  1. added
    enhancementAn improvement to something bngsim already does: refactors, lifted refusals, tooling
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn improvement to something bngsim already does: refactors, lifted refusals, tooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions