Files
EquationMiner/tests/conftest.py
T
davideandClaude Sonnet 5.5 da0964be4d Output organizzato per analisi: cartella input/, output/<csv>/ con domini, sovrapposizione e report
- dati/ rinominata input/ (CSV ignorati, cartella tracciata con .gitkeep)
- lavoro/ sostituita da output/<nome csv>/{01_domini,02_sovrapposizione,03_report}
- report.md con indice, tabella equazioni e immagini incorporate
- sovrapposizione complessiva dati-equazioni per serie

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:18:12 +01:00

44 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Fixture comuni: configurazione, segnale sintetico (verità nota) e CSV generati da gen_data (se presenti)."""
from pathlib import Path
import numpy as np
import pytest
from fitseg import config
RADICE = Path(__file__).parent.parent
SEEDS = [1, 2, 3]
# verità del segnale sintetico
TAU, T_AMB = 16.0, 23.0
GRADINI = [(15.0, 80.0), (18.0, 70.0), (22.0, 60.0)] # (istante [s], ampiezza [°C])
@pytest.fixture(scope="session")
def cfg():
return config.leggi(RADICE / "config.toml")
def segnale(rumore=0.1, seed=0, gradini=GRADINI, durata=120.0, dt=0.15):
"""T(t) = ambiente + Σ ampiezza·exp(−(t−t_j)/τ) per t ≥ t_j, più rumore gaussiano: nessun disturbo a salto."""
rng = np.random.default_rng(seed)
t = np.arange(dt, durata, dt)
x = sum(a * np.exp(-(t - tj) / TAU) * (t >= tj) for tj, a in gradini) if gradini else np.zeros_like(t)
T = T_AMB + x + rumore * rng.standard_normal(len(t))
return t, {"T_C": T, "dT_C": T - T_AMB}
@pytest.fixture(scope="session")
def sintetico():
return segnale()
@pytest.fixture(params=SEEDS)
def csv_gen(request):
"""CSV prodotto da gen_data per il seed; il test è saltato se il file non c'è (input/*.csv non è in git)."""
percorso = RADICE / f"input/gen_{request.param}.csv"
if not percorso.exists():
pytest.skip(f"{percorso} assente: rigenera con gen_data (vedi README)")
return percorso