@@ -70,24 +70,26 @@ def flatten(arr):
7070 )
7171
7272
73- def pretty_print_values (popt , pcov , params ):
73+ def pretty_print_values (popt , pcov , params , extra_decimal_places = 0 ):
7474 """
7575 Takes a numpy array of parameters, the corresponding covariance matrix
7676 and a set of parameter names and prints the parameters and
7777 principal 1-s.d.uncertainties (np.sqrt(pcov[i][i]))
7878 in a nice text based format.
7979 """
8080 for i , p in enumerate (params ):
81- p_rnd = round_to_n (popt [i ], np .sqrt (pcov [i ][i ]), 1 )
82- c_rnd = round_to_n (np .sqrt (pcov [i ][i ]), np .sqrt (pcov [i ][i ]), 1 )
81+ p_rnd = round_to_n (popt [i ], np .sqrt (pcov [i ][i ]), 1 + extra_decimal_places )
82+ c_rnd = round_to_n (
83+ np .sqrt (pcov [i ][i ]), np .sqrt (pcov [i ][i ]), 1 + extra_decimal_places
84+ )
8385
8486 if p_rnd != 0.0 :
8587 p_expnt = np .floor (np .log10 (np .abs (p_rnd )))
8688 else :
8789 p_expnt = 0.0
8890
8991 scale = np .power (10.0 , p_expnt )
90- nd = p_expnt - np .floor (np .log10 (np .abs (c_rnd )))
92+ nd = p_expnt - np .floor (np .log10 (np .abs (c_rnd ))) + extra_decimal_places
9193 print (
9294 "{0:s}: ({1:{4}{5}f} +/- {2:{4}{5}f}) x {3:.0e}" .format (
9395 p , p_rnd / scale , c_rnd / scale , scale , 0 , (nd ) / 10.0
0 commit comments