File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -919,10 +919,23 @@ def scan_likelihood_1d(
919919 # calculate upper bound for scan
920920 if ("n_s" in param_name ) and adjust_bound :
921921 logger .debug ("adjusting bound" )
922- best [i ] = bound [1 ]
923- while g (best ) > (min_llh + upper_bound_level ** 2 ):
924- best [i ] *= factor
925- ur = min (bound [1 ], max (best [i ], 0 ))
922+ if bound [1 ] is None :
923+ ur = scipy .optimize .fmin_l_bfgs_b (
924+ lambda x : np .abs (
925+ g ([* best [:i ], x [0 ], * best [i + 1 :]])
926+ - (min_llh + upper_bound_level ** 2 )
927+ ),
928+ x0 = best [i ] / factor ,
929+ bounds = [(best [i ], None )],
930+ approx_grad = True ,
931+ disp = False ,
932+ factr = 1e12 ,
933+ )[0 ][0 ]
934+ else :
935+ best [i ] = bound [1 ]
936+ while g (best ) > (min_llh + upper_bound_level ** 2 ):
937+ best [i ] *= factor
938+ ur = min (bound [1 ], max (best [i ], 0 ))
926939 else :
927940 ur = bound [1 ]
928941
You can’t perform that action at this time.
0 commit comments