Coverage for src/tinycta/config.py: 100%
14 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-06 05:36 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-06 05:36 +0000
1"""Configuration model for the Basanos engine."""
3from pydantic import BaseModel, Field, ValidationInfo, field_validator
6class Config(BaseModel):
7 """Configuration for correlation-aware position optimization (Basanos engine)."""
9 vola: int = Field(..., gt=0)
10 corr: int = Field(..., gt=0)
11 clip: float = Field(..., gt=0.0)
12 shrink: float = Field(..., ge=0.0, le=1.0)
14 model_config = {"frozen": True, "extra": "forbid"}
16 @field_validator("corr")
17 @classmethod
18 def corr_greater_than_vola(cls, v: int, info: ValidationInfo) -> int:
19 """Enforce corr >= vola for numerical stability."""
20 vola = info.data.get("vola") if hasattr(info, "data") else None
21 if vola is not None and v < vola:
22 raise ValueError
23 return v