Commit 3a56cffd authored by Gaetano Scandariato's avatar Gaetano Scandariato
Browse files

style: resolve remaining ruff linter warnings and clean technical debt

- Rename ambiguous single-character variables (E741) across plotting and physics modules
- Flatten nested control structures using boolean logic (SIM102)
- Rename unused loop variables with leading underscore (B007)
- Remove unused loop enumerations and redundant ternary expressions (RUF034)
- Re-export GP kernel factory functions in PyAETNA.gp for backward compatibility
- Fix type imports and regex escaping in test suite (UP035, RUF043)
- Verify 100% test suite pass-rate across all 265 test cases
parent d08bb65e
Loading
Loading
Loading
Loading
+5 −0
Changes for PyAETNA/gp.py: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@ import numpy as np
from tinygp import GaussianProcess

# Import kernel functions from the new dedicated kernels/factory.py module
from PyAETNA.kernels.factory import (
    build_gp_kernel_for_plotting,
    build_gp_kernel_for_sampling,
    build_gp_kernel_from_specs,
)

# =============================================================================
# GP Prediction (JIT-compiled for speed)
+2 −4
Changes for PyAETNA/planet_phys.py: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -1542,7 +1542,7 @@ def compute_derived_quantities(
                }
            )
        else:
            for dname, darr, dmap in orbital_names:
            for dname, _darr, dmap in orbital_names:
                derived_fixed[dname] = dmap

        if is_circular:
@@ -1791,9 +1791,7 @@ def compute_derived_quantities(
            # Explicitly mark these as measured for coloring.
            # Even if they come from derived_samples, they act as inputs for Mass.
            for p in measured_planet_mp:
                if p is not None:
                    # Don't add if already there (avoid duplicates if possible, though not harmful)
                    if p not in force_measured_label:
                if p is not None and p not in force_measured_label:
                    force_measured_label.append(p)

            # Derived planetary mass (and derived eccentricity)
+5 −5
Changes for PyAETNA/reporting/corner_plot.py: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -886,11 +886,11 @@ def plot_kde_trace(
    seen = set()
    unique_handles = []
    unique_labels = []
    for h, l in zip(all_handles, all_labels):
        if l not in seen:
    for h, lbl in zip(all_handles, all_labels):
        if lbl not in seen:
            unique_handles.append(h)
            unique_labels.append(l)
            seen.add(l)
            unique_labels.append(lbl)
            seen.add(lbl)

    # Aim for ≤ 30 items per column; split to multiple columns for many chains
    n_legend_items = len(unique_labels)
@@ -947,7 +947,7 @@ def plot_visit_kde(samples_dict, param_prefix, plModel, num_chains=1, figsize=(1
    # Compute overall x-range across all visits (using 99.9% quantiles)
    all_q_low = []
    all_q_high = []
    for uf, pname in visit_params.items():
    for _uf, pname in visit_params.items():
        samples = samples_dict[pname]
        all_q_low.append(np.percentile(samples, 0.05))
        all_q_high.append(np.percentile(samples, 99.95))
+1 −1
Changes for PyAETNA/reporting/map_search.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -828,7 +828,7 @@ def _compute_loglikelihood_fast(params, param_config, plModel, ctx):
    total_loglike = 0.0
    if ctx["gp_static"]:
        residuals = y_arr - det_arr
        for inst_id, gs in ctx["gp_static"].items():
        for _inst_id, gs in ctx["gp_static"].items():
            idx = gs["idx"]
            res_inst = residuals[idx]
            dy_inst = dy_arr[idx]
+1 −2
Changes for PyAETNA/reporting/noise_plots.py: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -120,8 +120,7 @@ def plot_noise_budget(
        if jitter_mask_specs is not None:
            inst_mask_local = instrument_arr == inst_id
            for spec in jitter_mask_specs:
                if spec[0] == "visit":
                    if np.any((visit_arr == spec[1]) & inst_mask_local):
                if spec[0] == "visit" and np.any((visit_arr == spec[1]) & inst_mask_local):
                    return True
        return False

Loading