3535from __future__ import annotations
3636
3737from dataclasses import dataclass
38- from typing import Callable , Optional , Tuple
3938
4039import numpy as np
4140
4241try :
4342 # SciPy is used for linear programming; HiGHS is fast and reliable.
4443 from scipy .optimize import linprog # type: ignore
45- except Exception as e : # pragma: no cover
44+ except Exception : # pragma: no cover
4645 linprog = None # type: ignore
4746
4847
@@ -68,12 +67,12 @@ class CalibrationResult:
6867
6968 w : np .ndarray
7069 epsilon : float
71- t : Optional [ float ]
70+ t : float | None
7271 status : int
7372 message : str
7473
7574
76- def _validate_inputs (A : np .ndarray , b : np .ndarray , w0 : np .ndarray ) -> Tuple [np .ndarray , np .ndarray , np .ndarray ]:
75+ def _validate_inputs (A : np .ndarray , b : np .ndarray , w0 : np .ndarray ) -> tuple [np .ndarray , np .ndarray , np .ndarray ]:
7776 """Validate and coerce input arrays to ensure they have compatible shapes.
7877
7978 Parameters
@@ -233,7 +232,7 @@ def leximin_weight_fair(
233232 max_ratio : float = 10.0 ,
234233 slack : float = 0.0 ,
235234 return_stages : bool = False ,
236- ) -> CalibrationResult | Tuple [CalibrationResult , CalibrationResult ]:
235+ ) -> CalibrationResult | tuple [CalibrationResult , CalibrationResult ]:
237236 r"""Compute weights via residual leximin followed by weight-fair refinement.
238237
239238 This function first solves the residual minimisation problem as in
@@ -341,4 +340,4 @@ def leximin_weight_fair(
341340 stage2 = CalibrationResult (w = w , epsilon = epsilon_opt , t = t_opt , status = res .status , message = res .message )
342341 if return_stages :
343342 return stage1 , stage2
344- return stage2
343+ return stage2
0 commit comments