@@ -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 ()
@@ -160,7 +157,7 @@ def conv_none(value):
160157 mask_by_value_dict [mc ["column" ]] = {mc ["find_by_value" ]: conv_none (mc ["mask_with" ])}
161158
162159 # Mask all we can do by value
163- df_to_mask .replace (mask_by_value_dict , inplace = True )
160+ df_to_mask = df_to_mask .replace (mask_by_value_dict )
164161
165162 # Now mask all which are searched by query
166163 for mc in mask_by_query_list :
@@ -308,12 +305,12 @@ def make_latex_table(column_names, row_names, rows, caption=None, save_path="./t
308305 columns = "|" .join (["c" ] * (len (column_names ) + 1 ))
309306 f .write ("\\ begin{tabular}{" + columns + "}\n " )
310307 f .write ("\\ hline\n " )
311- columns = "&" .join (["" ] + column_names )
308+ columns = "&" .join (["" , * column_names ] )
312309 columns = columns .replace ("_" , "\\ _" )
313310 f .write (columns + "\\ \\ \n " )
314311 f .write ("\\ hline\\ hline\n " )
315- for rn , row in zip (row_names , rows ):
316- row_string = "&" .join ([rn ] + row )
312+ for rn , row in zip (row_names , rows , strict = False ):
313+ row_string = "&" .join ([rn , * row ] )
317314 row_string = row_string .replace ("_" , "\\ _" )
318315 f .write (row_string + "\\ \\ \n " )
319316 f .write ("\\ end{tabular}\n " )
@@ -411,10 +408,7 @@ def equal_axis_list(axis1, list2, precision=10):
411408 bins = get_bins (axis1 )
412409 if len (bins ) != len (list2 ):
413410 return False
414- for i , j in zip (bins , list2 ):
415- if round (i , precision ) != round (j , precision ):
416- return False
417- return True
411+ return all (round (i , precision ) == round (j , precision ) for i , j in zip (bins , list2 , strict = False ))
418412
419413
420414def equal_binning (his1 , his2 ):
@@ -432,9 +426,7 @@ def equal_binning_lists(his, list_x=None, list_y=None, list_z=None):
432426 return False
433427 if list_y is not None and not equal_axis_list (his .GetYaxis (), list_y ):
434428 return False
435- if list_z is not None and not equal_axis_list (his .GetZaxis (), list_z ):
436- return False
437- return True
429+ return not (list_z is not None and not equal_axis_list (his .GetZaxis (), list_z ))
438430
439431
440432def folding (h_input , response_matrix , h_output ):
@@ -943,13 +935,13 @@ def plot_latex(latex):
943935 # set canvas margins
944936 if isinstance (margins_c , list ) and len (margins_c ) > 0 :
945937 for setter , value in zip (
946- [can .SetBottomMargin , can .SetLeftMargin , can .SetTopMargin , can .SetRightMargin ], margins_c
938+ [can .SetBottomMargin , can .SetLeftMargin , can .SetTopMargin , can .SetRightMargin ], margins_c , strict = False
947939 ):
948940 setter (value )
949941 # set logarithmic scale for selected axes
950942 log_y = False
951943 if isinstance (logscale , str ) and len (logscale ) > 0 :
952- for setter , axis in zip ([can .SetLogx , can .SetLogy , can .SetLogz ], ["x" , "y" , "z" ]):
944+ for setter , axis in zip ([can .SetLogx , can .SetLogy , can .SetLogz ], ["x" , "y" , "z" ], strict = False ):
953945 if axis in logscale :
954946 setter ()
955947 if axis == "y" :
0 commit comments