refactor: simplify best lag value handling in energy correlation calculations
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

- Updated the `_correlate_energy_weight` function to streamline the unpacking of the `best` variable, removing unnecessary tuple elements for improved clarity and efficiency in the correlation logic.
This commit is contained in:
Lars 2026-04-21 08:12:21 +02:00
parent 0365d9eb52
commit 1c512b0d0a

View File

@ -170,7 +170,7 @@ def _correlate_energy_weight(profile_id: str, max_lag: int) -> Optional[Dict]:
balance_by = {d: kcal_by[d] - tdee_f for d in kcal_by} balance_by = {d: kcal_by[d] - tdee_f for d in kcal_by}
best: Optional[Tuple[int, float, int, List[Tuple[int, float]]]] = None best: Optional[Tuple[int, float, int]] = None
lag_details: List[Dict[str, Any]] = [] lag_details: List[Dict[str, Any]] = []
max_l = max(0, min(int(max_lag), 28)) max_l = max(0, min(int(max_lag), 28))
@ -211,7 +211,7 @@ def _correlate_energy_weight(profile_id: str, max_lag: int) -> Optional[Dict]:
"tdee_kcal_used": round(tdee_f, 0), "tdee_kcal_used": round(tdee_f, 0),
} }
lag_b, r_b, n_b, _ = best lag_b, r_b, n_b = best
direction = _direction_from_r(r_b) direction = _direction_from_r(r_b)
conf = _lag_confidence(n_b, r_b) conf = _lag_confidence(n_b, r_b)
interp = ( interp = (