-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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.52. 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 * cage3. 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
- PR feat: Implement SCORE2 cardiovascular risk assessment algorithm #2: feat: Implement SCORE2 cardiovascular risk assessment algorithm
- Follows Python coding style guidelines for clarity
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request