Issue Description
The SCORE2 implementation is missing type hints for some variables and could benefit from more comprehensive typing.
Current State
- Function signatures have type hints
- Some internal variables lack type hints
- Could improve code clarity and IDE support
Suggested Improvements
1. Add type hints for transformed variables
# Current
cage = (age - 60) / 5
smoking = float(biomarkers.smoking)
# Improved
cage: float = (age - 60) / 5
smoking: float = float(biomarkers.smoking)
csbp: float = (biomarkers.systolic_blood_pressure - 120) / 20
ctchol: float = biomarkers.total_cholesterol - 6
chdl: float = (biomarkers.hdl_cholesterol - 1.3) / 0.5
2. Add type hints for interaction terms
smoking_age: float = smoking * cage
sbp_age: float = csbp * cage
tchol_age: float = ctchol * cage
hdl_age: float = chdl * cage
3. Add type hints for intermediate calculations
x: float = (...) # Linear predictor
uncalibrated_risk: float = 1 - np.power(baseline_survival, np.exp(x))
4. Consider using TypeAlias for risk categories
from typing import Literal, TypeAlias
RiskCategory: TypeAlias = Literal["Low to moderate", "High", "Very high"]
Impact
- Better IDE support and code completion
- Easier to understand variable types at a glance
- Helps catch type-related bugs early
- Improves code maintainability
Related
Issue Description
The SCORE2 implementation is missing type hints for some variables and could benefit from more comprehensive typing.
Current State
Suggested Improvements
1. Add type hints for transformed variables
2. Add type hints for interaction terms
3. Add type hints for intermediate calculations
4. Consider using TypeAlias for risk categories
Impact
Related