Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """Offline smoke tests for the Gradio weather app core.""" | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| import pandas as pd | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from weatherpred.config import FORECAST_DAYS | |
| from weatherpred.modeling import seasonal_reference | |
| def main() -> None: | |
| dates = pd.date_range("2020-01-01", periods=400, freq="D") | |
| history = pd.DataFrame( | |
| { | |
| "date": dates, | |
| "high_c": [20.0 + (index % 10) for index in range(len(dates))], | |
| "low_c": [12.0 + (index % 7) for index in range(len(dates))], | |
| "rain_mm": [float(index % 3) for index in range(len(dates))], | |
| "wind_kmh": [10.0 + (index % 5) for index in range(len(dates))], | |
| "confidence": 1.0, | |
| } | |
| ) | |
| forecast_dates = list(pd.date_range("2021-02-04", periods=FORECAST_DAYS, freq="D")) | |
| reference = seasonal_reference(history, forecast_dates) | |
| assert len(reference) == FORECAST_DAYS | |
| assert {"seasonal_low_gap", "rain_mm", "wind_kmh", "high_std"}.issubset(reference.columns) | |
| assert reference["rain_mm"].notna().all() | |
| print("Gradio app core smoke test passed.") | |
| if __name__ == "__main__": | |
| main() | |