mirror of
https://github.com/lynchaos/ashvale-station.git
synced 2026-09-12 12:47:49 +00:00
chore: enforce ruff config and fix lint findings
This commit is contained in:
@@ -29,6 +29,11 @@ jobs:
|
||||
pip install -r requirements.txt
|
||||
pip install httpx
|
||||
|
||||
- name: Lint
|
||||
run: |
|
||||
pip install ruff
|
||||
ruff check .
|
||||
|
||||
- name: Byte-compile every module
|
||||
run: python -m compileall -q ashvale scripts run.py
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ Two jobs here, both familiar from soft-sensor work:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, Optional
|
||||
|
||||
|
||||
+8
-2
@@ -32,8 +32,14 @@ from typing import Dict, List, Tuple
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .physics import (absolute_humidity, clear_sky_irradiance, dew_point,
|
||||
solar_position, vapour_pressure_deficit, wet_bulb)
|
||||
from .physics import (
|
||||
absolute_humidity,
|
||||
clear_sky_irradiance,
|
||||
dew_point,
|
||||
solar_position,
|
||||
vapour_pressure_deficit,
|
||||
wet_bulb,
|
||||
)
|
||||
|
||||
FEATURE_NAMES: List[str] = [
|
||||
"bias",
|
||||
|
||||
+1
-2
@@ -34,8 +34,7 @@ matters.
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
from typing import Dict, List, Sequence, Tuple
|
||||
from typing import List, Sequence, Tuple
|
||||
|
||||
OFF = (0, 0, 0)
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from .rls import RecursiveLeastSquares, AdaptiveConformal
|
||||
from .nowcast import NowcastEnsemble
|
||||
from .climatology import HarmonicClimatology
|
||||
from .precip import PrecipitationModel, zambretti
|
||||
from .anomaly import AnomalyMonitor
|
||||
from .climatology import HarmonicClimatology
|
||||
from .nowcast import NowcastEnsemble
|
||||
from .precip import PrecipitationModel, zambretti
|
||||
from .rls import AdaptiveConformal, RecursiveLeastSquares
|
||||
|
||||
__all__ = [
|
||||
"RecursiveLeastSquares", "AdaptiveConformal", "NowcastEnsemble",
|
||||
|
||||
@@ -141,9 +141,9 @@ class HarmonicClimatology:
|
||||
sigma0 = self.resid_std.get(target, 1.0)
|
||||
sigma = sigma0 * np.sqrt(1.0 + lead_h / 24.0)
|
||||
return [
|
||||
{"ts": float(t), "lead_h": float(l), "mu": float(m),
|
||||
{"ts": float(t), "lead_h": float(lh), "mu": float(m),
|
||||
"lo": float(m - 1.645 * s), "hi": float(m + 1.645 * s)}
|
||||
for t, l, m, s in zip(grid, lead_h, mu, sigma)
|
||||
for t, lh, m, s in zip(grid, lead_h, mu, sigma)
|
||||
]
|
||||
|
||||
def anomaly_now(self, target: str, ts: float, observed: float) -> float:
|
||||
|
||||
@@ -39,7 +39,7 @@ from __future__ import annotations
|
||||
|
||||
import math
|
||||
import time
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ same code to the Pi unchanged.
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
import random
|
||||
import time
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
|
||||
+1
-2
@@ -34,7 +34,6 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import math
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
@@ -44,7 +43,7 @@ import numpy as np
|
||||
from . import physics
|
||||
from .config import Config
|
||||
from .estimation import SignalTracker
|
||||
from .features import N_FEATURES, build_features
|
||||
from .features import build_features
|
||||
from .models.anomaly import AnomalyMonitor
|
||||
from .models.climatology import HarmonicClimatology
|
||||
from .models.nowcast import NowcastEnsemble
|
||||
|
||||
+4
-1
@@ -77,5 +77,8 @@ line-length = 100
|
||||
target-version = "py39"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "W", "I", "UP", "B"]
|
||||
# UP is deliberately absent. With target-version = "py39" it fights the
|
||||
# `from __future__ import annotations` style used throughout and generates
|
||||
# several hundred findings for no behavioural gain. B currently finds nothing.
|
||||
select = ["E", "F", "W", "I"]
|
||||
ignore = ["E501"]
|
||||
|
||||
+3
-1
@@ -163,7 +163,9 @@ def main() -> None:
|
||||
f"{r['bias']:>+8.3f} {r['weights']}{flag}")
|
||||
print()
|
||||
|
||||
print(f"units: temperature C, humidity %, pressure hPa")
|
||||
# Driven off the dict rather than hardcoded, so adding a target cannot leave
|
||||
# the units line silently describing the wrong columns.
|
||||
print("units: " + ", ".join(f"{t} {units[t]}" for t in cfg.model.targets if t in units))
|
||||
print("coverage should sit near 90% if the conformal calibration is honest.")
|
||||
|
||||
|
||||
|
||||
+6
-2
@@ -52,8 +52,12 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from ashvale.config import load_config # noqa: E402
|
||||
from ashvale.estimation import SignalTracker # noqa: E402
|
||||
from ashvale.physics import (dew_point, sea_level_pressure, # noqa: E402
|
||||
solar_position, clear_sky_irradiance)
|
||||
from ashvale.physics import ( # noqa: E402
|
||||
clear_sky_irradiance,
|
||||
dew_point,
|
||||
sea_level_pressure,
|
||||
solar_position,
|
||||
)
|
||||
from ashvale.storage import Store # noqa: E402
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user