pytams.diagnostic ================= .. py:module:: pytams.diagnostic .. autoapi-nested-parse:: Diagnostic class for pyTAMS. Classes ------- .. autoapisummary:: pytams.diagnostic.DiagnosticPlugin pytams.diagnostic.ScoreThresholdDiagnostic pytams.diagnostic.DiagnosticAnalyst Functions --------- .. autoapisummary:: pytams.diagnostic.diagnosticfactory Module Contents --------------- .. py:class:: DiagnosticPlugin(dlabel: str, params: dict[Any, Any], tid: int, weight: float, workdir: pathlib.Path, fprocess: collections.abc.Callable[Ellipsis, Any], ddb: pytams.diagdb.DiagDB) A base class for diagnostic plugins. Plugins are attached to the trajectory objects. :ivar _label: the diagnostic label :ivar _tid: the ID of the trajectory the plugin is attached to :ivar _weight: the weight of the trajectory .. py:method:: get_crossed_levels(new_snapshot: pytams.snapshot.Snapshot) -> list[float] :abstractmethod: Test to know if diagnostic is needed. .. py:method:: update(old_snapshot: pytams.snapshot.Snapshot, new_snapshot: pytams.snapshot.Snapshot) -> None Standard entry point called after every MCMC step. .. py:class:: ScoreThresholdDiagnostic(dlabel: str, params: dict[Any, Any], tid: int, tweight: float, workdir: pathlib.Path, fprocess: collections.abc.Callable[Ellipsis, Any], ddb: pytams.diagdb.DiagDB) Bases: :py:obj:`DiagnosticPlugin` Triggers when the score function crosses pre-defined levels. .. py:method:: get_crossed_levels(new_snapshot: pytams.snapshot.Snapshot) -> list[float] Get the list of level crossed during last step. :param new_snapshot: the new (end of the time step) snapshot :returns: the list of score levels crossed .. py:function:: diagnosticfactory(params: dict[Any, Any], tid: int, tweight: float, workdir: pathlib.Path, fprocess: collections.abc.Callable[Ellipsis, Any], ddb: pytams.diagdb.DiagDB) -> list[DiagnosticPlugin] Parse input parameters to generate a list of DiagnosticPlugin. :param params: the input parameters :param tid: the ID of the traj the diagnostic is attached to :param tweight: the weight of the traj :param workdir: the workdir associated with a trajectory :param fprocess: the forward model diagnostic function :param ddb: the diagnostic database to add the data to .. py:class:: DiagnosticAnalyst(db_path: str) A class to handle analysing diagnostic statistics. Let's keep the analysis logic separated from the gathering logic. This class retrieves data from the diagnostic database and perform some computation (mostly conditional statistics on score iso-levels). .. py:attribute:: db .. py:method:: get_diagnostic_data(label: str) -> dict[float, list[tuple[Any, float]]] A user-facing access to the diag DB. An alias to the DB access for the analyst. :returns: A dictionary mapping each score iso-level (float) to a list of tuples. Each tuple contains (unpickled_data, trajectory_weight). .. py:method:: compute_weighted_stats(label: str) -> dict[float, dict[str, Any]] Aggregate data and compute mean/variance per level.