@@ -128,10 +128,7 @@ def write_df(dfo, path):
128128
129129def read_df (path , ** kwargs ):
130130 try :
131- if path .endswith (".parquet" ):
132- df = pd .read_parquet (path , ** kwargs )
133- else :
134- df = pickle .load (openfile (path , "rb" ))
131+ df = pd .read_parquet (path , ** kwargs ) if path .endswith (".parquet" ) else pickle .load (openfile (path , "rb" ))
135132 except Exception as e : # pylint: disable=broad-except
136133 logger .critical ("failed to open file <%s>: %s" , path , str (e ))
137134 sys .exit ()
@@ -294,12 +291,12 @@ def make_latex_table(column_names, row_names, rows, caption=None, save_path="./t
294291 columns = "|" .join (["c" ] * (len (column_names ) + 1 ))
295292 f .write ("\\ begin{tabular}{" + columns + "}\n " )
296293 f .write ("\\ hline\n " )
297- columns = "&" .join (["" ] + column_names )
294+ columns = "&" .join (["" , * column_names ] )
298295 columns = columns .replace ("_" , "\\ _" )
299296 f .write (columns + "\\ \\ \n " )
300297 f .write ("\\ hline\\ hline\n " )
301- for rn , row in zip (row_names , rows ):
302- row_string = "&" .join ([rn ] + row )
298+ for rn , row in zip (row_names , rows , strict = False ):
299+ row_string = "&" .join ([rn , * row ] )
303300 row_string = row_string .replace ("_" , "\\ _" )
304301 f .write (row_string + "\\ \\ \n " )
305302 f .write ("\\ end{tabular}\n " )
@@ -349,12 +346,12 @@ def make_message_notfound(name, location=None):
349346
350347
351348def z_calc (pt_1 , phi_1 , eta_1 , pt_2 , phi_2 , eta_2 ):
352- np_pt_1 = pt_1 .values
353- np_pt_2 = pt_2 .values
354- np_phi_1 = phi_1 .values
355- np_phi_2 = phi_2 .values
356- np_eta_1 = eta_1 .values
357- np_eta_2 = eta_2 .values
349+ np_pt_1 = pt_1 .to_numpy ()
350+ np_pt_2 = pt_2 .to_numpy ()
351+ np_phi_1 = phi_1 .to_numpy ()
352+ np_phi_2 = phi_2 .to_numpy ()
353+ np_eta_1 = eta_1 .to_numpy ()
354+ np_eta_2 = eta_2 .to_numpy ()
358355
359356 cos_phi_1 = np .cos (np_phi_1 )
360357 cos_phi_2 = np .cos (np_phi_2 )
@@ -397,10 +394,7 @@ def equal_axis_list(axis1, list2, precision=10):
397394 bins = get_bins (axis1 )
398395 if len (bins ) != len (list2 ):
399396 return False
400- for i , j in zip (bins , list2 ):
401- if round (i , precision ) != round (j , precision ):
402- return False
403- return True
397+ return all (round (i , precision ) == round (j , precision ) for i , j in zip (bins , list2 , strict = False ))
404398
405399
406400def equal_binning (his1 , his2 ):
@@ -418,9 +412,7 @@ def equal_binning_lists(his, list_x=None, list_y=None, list_z=None):
418412 return False
419413 if list_y is not None and not equal_axis_list (his .GetYaxis (), list_y ):
420414 return False
421- if list_z is not None and not equal_axis_list (his .GetZaxis (), list_z ):
422- return False
423- return True
415+ return not (list_z is not None and not equal_axis_list (his .GetZaxis (), list_z ))
424416
425417
426418def folding (h_input , response_matrix , h_output ):
@@ -939,13 +931,13 @@ def plot_latex(latex):
939931 # set canvas margins
940932 if isinstance (margins_c , list ) and len (margins_c ) > 0 :
941933 for setter , value in zip (
942- [can .SetBottomMargin , can .SetLeftMargin , can .SetTopMargin , can .SetRightMargin ], margins_c
934+ [can .SetBottomMargin , can .SetLeftMargin , can .SetTopMargin , can .SetRightMargin ], margins_c , strict = False
943935 ):
944936 setter (value )
945937 # set logarithmic scale for selected axes
946938 log_y = False
947939 if isinstance (logscale , str ) and len (logscale ) > 0 :
948- for setter , axis in zip ([can .SetLogx , can .SetLogy , can .SetLogz ], ["x" , "y" , "z" ]):
940+ for setter , axis in zip ([can .SetLogx , can .SetLogy , can .SetLogz ], ["x" , "y" , "z" ], strict = False ):
949941 if axis in logscale :
950942 setter ()
951943 if axis == "y" :
@@ -1349,7 +1341,7 @@ def format_value_with_unc(y, e_stat=None, e_syst_plus=None, e_syst_minus=None, n
13491341 if str_e_syst_plus == str_e_syst_minus :
13501342 str_value += f" ± { str_e_syst_plus } (syst.)"
13511343 else :
1352- str_value += f" +{ str_e_syst_plus } −{ str_e_syst_minus } (syst.)"
1344+ str_value += f" +{ str_e_syst_plus } −{ str_e_syst_minus } (syst.)" # noqa: RUF001
13531345 return str_value
13541346
13551347
0 commit comments