mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-22 19:41:14 +00:00
refactor(01-01): convert hot-path schemas/*.py to hot_types re-export shims
- schemas/eskf.py: keep ConfidenceTier + ESKFConfig; re-export IMUSample and ESKFState from hot_types (define ConfidenceTier BEFORE the hot_types imports to avoid circular import — eskf_state.py imports ConfidenceTier from this module). Legacy alias IMUMeasurement = IMUSample. - schemas/vo.py: re-export Features, Matches, RelativePose, Motion, VOEstimate from hot_types.vo_estimate. - schemas/satellite.py: re-export TileCoords, TileBounds, SatelliteAnchor. - schemas/metric.py: keep LiteSAMConfig; re-export AlignmentResult, ChunkAlignmentResult, Sim3Transform. - schemas/rotation.py: keep HeadingHistory + RotationConfig; re-export RotationResult. Auto-fixes (Rules 1 + 3) needed to keep the 216-test floor green: - core/rotation.py: refactor try_rotation_steps to use dataclasses.replace instead of attribute assignment on RotationResult (Rule 1 — frozen dataclass forbids mutation; Pydantic silently allowed it). PATTERNS.md §6.1 already flagged Pose mutation but missed this site. - hot_types/vo_estimate.py: add Optional `covariance: np.ndarray` field to RelativePose (Rule 3 — five test sites construct RelativePose with `covariance=np.eye(6)`; Pydantic v2 silently accepted the extra kwarg via default `extra="ignore"`. Declaring the field preserves the construction contract under the dataclass migration without editing tests). Verification: pytest tests/ -q --ignore=tests/e2e → 216 passed, 8 skipped (matches baseline). Accuracy bench (23 tests) passes.
This commit is contained in:
@@ -1,24 +1,16 @@
|
||||
"""Rotation schemas (Component F06)."""
|
||||
"""Rotation schemas (Component F06).
|
||||
|
||||
Phase 1 shim — hot-path `RotationResult` lives in
|
||||
`gps_denied.hot_types.rotation_result`. `HeadingHistory` (mutable
|
||||
bookkeeping) and `RotationConfig` (config) stay here as Pydantic.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class RotationResult(BaseModel):
|
||||
"""Result of a rotation sweep alignment."""
|
||||
matched: bool
|
||||
initial_angle: float
|
||||
precise_angle: float
|
||||
confidence: float
|
||||
# We will exclude np.ndarray from BaseModel to avoid validation issues,
|
||||
# but store it as an attribute if needed or use arbitrary_types_allowed.
|
||||
|
||||
model_config = {"arbitrary_types_allowed": True}
|
||||
homography: Optional[np.ndarray] = None
|
||||
inlier_count: int = 0
|
||||
from gps_denied.hot_types.rotation_result import RotationResult # noqa: F401
|
||||
|
||||
|
||||
class HeadingHistory(BaseModel):
|
||||
@@ -36,3 +28,10 @@ class RotationConfig(BaseModel):
|
||||
sharp_turn_threshold: float = 45.0
|
||||
confidence_threshold: float = 0.7
|
||||
history_size: int = 10
|
||||
|
||||
|
||||
__all__ = [
|
||||
"HeadingHistory",
|
||||
"RotationConfig",
|
||||
"RotationResult",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user