Commit 36a4b0ce authored by Gaetano Scandariato's avatar Gaetano Scandariato
Browse files

style: flatten nested patch with-statements and define __all__ for public GP re-exports

- Flatten nested  calls in  (SIM117)
- Define  in  for public re-exported kernel functions (F401)
- Achieve 0 warnings/errors across all library and test modules in ruff check
parent 3a56cffd
Loading
Loading
Loading
Loading
+12 −0
Changes for PyAETNA/gp.py: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -60,6 +60,18 @@ from PyAETNA.kernels.factory import (
    build_gp_kernel_from_specs,
)

__all__ = [
    "build_gp_kernel_for_plotting",
    "build_gp_kernel_for_sampling",
    "build_gp_kernel_from_specs",
    "compute_kernel_theoretical_psd",
    "compute_windowed_psd",
    "get_gp_x_variable",
    "gp_log_probability_per_visit",
    "gp_predict",
    "gp_predict_per_visit",
]

# =============================================================================
# GP Prediction (JIT-compiled for speed)
# =============================================================================
+30 −42
Changes for tests/reporting/test_smoke.py: 30 added lines, 42 removed lines.
Original line number Diff line number Diff line
@@ -35,13 +35,11 @@ def test_generate_report_smoke():
    }

    # Mock load_numpyro_results to return our mock_data
    with patch(
    with (
        patch(
            "PyAETNA.reporting.pdf_report.load_numpyro_results", return_value=mock_data
    ):
        # We also need to mock find_map_parameters and compute_mcmc_diagnostics
        # because they might expect specific param_config structures or
        # perform heavy computations.
        with patch(
        ),
        patch(
            "PyAETNA.reporting.pdf_report.find_map_parameters",
            return_value={
                "map_params": {},
@@ -51,8 +49,8 @@ def test_generate_report_smoke():
                "map_chi2_red": 1.0,
                "map_idx": 0,
            },
        ):
            with patch(
        ),
        patch(
            "PyAETNA.reporting.pdf_report.compute_mcmc_diagnostics",
            return_value={
                "diagnostics": {},
@@ -63,6 +61,7 @@ def test_generate_report_smoke():
                "stuck_params": [],
                "low_ess_params": [],
            },
        ),
    ):
        # Mock the PDF generation part to avoid actually writing a large file
        # if we just want a smoke test, but since we are testing the pipeline,
@@ -77,52 +76,41 @@ def test_generate_report_smoke():
            mock_pdf = MagicMock()
            mock_pdf.__enter__.return_value = mock_pdf
            mock_pdf.savefig = MagicMock()
                    with patch(
                        "PyAETNA.reporting.pdf_report.PdfPages", return_value=mock_pdf
                    ):
                        with patch(
                            "PyAETNA.reporting.pdf_report.plot_models",
                            return_value=None,
                        ):
                            with patch(
                                "PyAETNA.reporting.pdf_report.plot_corner",
                                return_value=None,
                            ):
                                with patch(
            with (
                patch("PyAETNA.reporting.pdf_report.PdfPages", return_value=mock_pdf),
                patch("PyAETNA.reporting.pdf_report.plot_models", return_value=None),
                patch("PyAETNA.reporting.pdf_report.plot_corner", return_value=None),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_periodograms_comparison",
                    return_value=None,
                                ):
                                    with patch(
                                        "PyAETNA.reporting.pdf_report.plot_ttv_oc",
                                        return_value=None,
                                    ):
                                        with patch(
                                            "PyAETNA.reporting.pdf_report.plot_phase_folded",
                                            return_value=None,
                                        ):
                                            with patch(
                ),
                patch("PyAETNA.reporting.pdf_report.plot_ttv_oc", return_value=None),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_phase_folded", return_value=None
                ),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_phase_folded_rv",
                    return_value=None,
                                            ):
                                                with patch(
                ),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_phase_folded_rv_rm_zoom",
                    return_value=None,
                                                ):
                                                    with patch(
                ),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_ttv_per_transit",
                    return_value=None,
                                                    ):
                                                        with patch(
                ),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_ttv_transit_overlay",
                    return_value=None,
                                                        ):
                                                            with patch(
                                                                "PyAETNA.reporting.pdf_report.plot_noise_budget",
                                                                return_value=None,
                                                            ):
                                                                with patch(
                ),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_noise_budget", return_value=None
                ),
                patch(
                    "PyAETNA.reporting.pdf_report.plot_residuals_vs_dbasis",
                    return_value=None,
                ),
            ):
                generate_report(
                    pickle_path="mock.pckl",