LCOV - code coverage report
Current view: top level - src/pairinteraction_gui/page - lifetimes_page.py (source / functions) Hit Total Coverage
Test: coverage.info Lines: 30 33 90.9 %
Date: 2026-04-17 09:29:39 Functions: 5 6 83.3 %

          Line data    Source code
       1             : # SPDX-FileCopyrightText: 2025 PairInteraction Developers
       2             : # SPDX-License-Identifier: LGPL-3.0-or-later
       3           1 : from __future__ import annotations
       4             : 
       5           1 : import logging
       6           1 : from typing import TYPE_CHECKING
       7             : 
       8           1 : from pairinteraction_gui.calculate.calculate_lifetimes import ParametersLifetimes, calculate_lifetimes
       9           1 : from pairinteraction_gui.config import KetConfigLifetimes
      10           1 : from pairinteraction_gui.page.base_page import CalculationPage
      11           1 : from pairinteraction_gui.plotwidget.plotwidget import PlotLifetimes
      12           1 : from pairinteraction_gui.qobjects import show_status_tip
      13             : 
      14             : if TYPE_CHECKING:
      15             :     from pairinteraction_gui.calculate.calculate_lifetimes import ResultsLifetimes
      16             : 
      17           1 : logger = logging.getLogger(__name__)
      18             : 
      19             : 
      20           1 : class LifetimesPage(CalculationPage):
      21             :     """Page for calculating lifetimes."""
      22             : 
      23           1 :     title = "Lifetimes"
      24           1 :     tooltip = "Calculate the lifetimes and transition rates for a specified ket"
      25             : 
      26           1 :     ket_config: KetConfigLifetimes
      27           1 :     plotwidget: PlotLifetimes  # type: ignore[assignment]
      28             : 
      29           1 :     def setupWidget(self) -> None:
      30           1 :         super().setupWidget()
      31           1 :         show_status_tip(self, "Ready", timeout=1)
      32             : 
      33             :         # all attributes of instance BaseConfig will be added to the toolbox in postSetupWidget
      34           1 :         self.ket_config = KetConfigLifetimes(self)
      35             : 
      36           1 :     def _create_plot_widget(self) -> PlotLifetimes:  # type: ignore[override]
      37           1 :         return PlotLifetimes(self)
      38             : 
      39           1 :     def calculate(self) -> tuple[ParametersLifetimes, ResultsLifetimes]:  # type: ignore[override]
      40           1 :         params = ParametersLifetimes.from_page(self)
      41           1 :         results = calculate_lifetimes(params)
      42           1 :         return params, results
      43             : 
      44           1 :     def update_plot(self, parameters: ParametersLifetimes, results: ResultsLifetimes) -> None:  # type: ignore[override]
      45           0 :         super().update_plot(parameters, results)  # type: ignore[arg-type]
      46           0 :         self.ket_config.set_lifetime(results.lifetime)
      47           0 :         show_status_tip(self, "Finished updating plot. Tip: Click on a bar to see transition details.", logger=logger)
      48             : 
      49           1 :     def _get_export_notebook_template_name(self) -> str:
      50           1 :         return "lifetimes.ipynb"
      51             : 
      52           1 :     def _get_export_replacements(self) -> dict[str, str]:
      53           1 :         parameters = ParametersLifetimes.from_page(self)
      54           1 :         return parameters.to_replacement_dict()

Generated by: LCOV version 1.16