@@ -151,7 +151,9 @@ def calibrate(
151151 current_weights : Optional [Dict [str , float ]] = None ,
152152 min_events : int = MIN_IMPROVEMENTS , # per-class floor; applies to both improvement and fp_candidate classes
153153 project_id : Optional [str ] = None , # P1: restrict history to this project
154- domain_anchor : Optional [Dict [str , float ]] = None , # P3: constrain grid to ±DOMAIN_TOLERANCE of anchor
154+ domain_anchor : Optional [
155+ Dict [str , float ]
156+ ] = None , # P3: constrain grid to ±DOMAIN_TOLERANCE of anchor
155157 ) -> CalibrationResult :
156158 """Run self-calibration. Returns CalibrationResult with optimal weights.
157159
@@ -547,11 +549,13 @@ def _grid_search(
547549 max_p = int (MAX_PURITY_WEIGHT * GRID_STEP ) # purity ceiling: 0.25 * 20 = 5
548550
549551 if domain_anchor :
552+
550553 def _dim_bounds (key : str , hard_max : int = max_i ) -> Tuple [int , int ]:
551554 anchor_v = domain_anchor .get (key , 0.30 )
552555 lo = max (min_i , int (round (max (MIN_W , anchor_v - DOMAIN_TOLERANCE ) * GRID_STEP )))
553556 hi = min (hard_max , int (round (min (MAX_W , anchor_v + DOMAIN_TOLERANCE ) * GRID_STEP )))
554557 return lo , hi
558+
555559 ldr_lo , ldr_hi = _dim_bounds ("ldr" )
556560 inf_lo , inf_hi = _dim_bounds ("inflation" )
557561 ddc_lo , ddc_hi = _dim_bounds ("ddc" )
0 commit comments