Skip to content

Commit c6080b1

Browse files
committed
fix MegaLinter errors
1 parent b81e3ca commit c6080b1

2 files changed

Lines changed: 35 additions & 16 deletions

File tree

‎PWGHF/D2H/Macros/compute_fraction_cutvar.py‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,56 +293,56 @@ def main(config):
293293
hist_bin_title = f"bin # {ipt+1}; {pt_axis_title}#in ({pt_min}; {pt_max})"
294294

295295
hist_bin_title_rawy = hist_bin_title if is_draw_title[PlotType.Rawy] else ""
296-
canv_rawy, histos_rawy, leg_r = minimiser.plot_result(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_rawy)
296+
canv_rawy, histos_rawy, _leg_r = minimiser.plot_result(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_rawy)
297297
output.cd()
298298
if is_save_to_root_file[ObjectToSave.Canvas]:
299299
canv_rawy.Write()
300300
if is_save_to_root_file[ObjectToSave.RawYield]:
301-
for _, hist in histos_rawy.items():
301+
for _, hist in histos_rawy.values():
302302
hist.Write()
303303
if is_save_canvas_as_macro[PlotType.Rawy]:
304304
canv_rawy.SaveAs(f"canv_rawy_{ipt+1}.C")
305305

306306
hist_bin_title_unc = hist_bin_title if is_draw_title[PlotType.Unc] else ""
307-
canv_unc, histos_unc, leg_unc = minimiser.plot_uncertainties(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_unc)
307+
canv_unc, histos_unc, _leg_unc = minimiser.plot_uncertainties(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_unc)
308308
output.cd()
309309
if is_save_to_root_file[ObjectToSave.Canvas]:
310310
canv_unc.Write()
311311
if is_save_to_root_file[ObjectToSave.Uncertainty]:
312-
for _, hist in histos_unc.items():
312+
for _, hist in histos_unc.values():
313313
hist.Write()
314314
if is_save_canvas_as_macro[PlotType.Unc]:
315315
canv_unc.SaveAs(f"canv_unc_{ipt+1}.C")
316316

317317
hist_bin_title_rel_unc = hist_bin_title if is_draw_title[PlotType.RelUnc] else ""
318-
canv_rel_unc, histos_rel_unc, leg_rel_unc = minimiser.plot_relative_uncertainties(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_rel_unc)
318+
canv_rel_unc, histos_rel_unc, _leg_rel_unc = minimiser.plot_relative_uncertainties(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_rel_unc)
319319
output.cd()
320320
if is_save_to_root_file[ObjectToSave.Canvas]:
321321
canv_rel_unc.Write()
322322
if is_save_to_root_file[ObjectToSave.Uncertainty]:
323-
for _, hist in histos_rel_unc.items():
323+
for _, hist in histos_rel_unc.values():
324324
hist.Write()
325325
if is_save_canvas_as_macro[PlotType.RelUnc]:
326326
canv_rel_unc.SaveAs(f"canv_rel_unc_{ipt+1}.C")
327327

328328
hist_bin_title_eff = hist_bin_title if is_draw_title[PlotType.Eff] else ""
329-
canv_eff, histos_eff, leg_e = minimiser.plot_efficiencies(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_eff)
329+
canv_eff, histos_eff, _leg_e = minimiser.plot_efficiencies(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_eff)
330330
output.cd()
331331
if is_save_to_root_file[ObjectToSave.Canvas]:
332332
canv_eff.Write()
333333
if is_save_to_root_file[ObjectToSave.Efficiency]:
334-
for _, hist in histos_eff.items():
334+
for _, hist in histos_eff.values():
335335
hist.Write()
336336
if is_save_canvas_as_macro[PlotType.Eff]:
337337
canv_eff.SaveAs(f"canv_eff_{ipt+1}.C")
338338

339339
hist_bin_title_frac = hist_bin_title if is_draw_title[PlotType.Frac] else ""
340-
canv_frac, histos_frac, leg_f = minimiser.plot_fractions(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_frac)
340+
canv_frac, histos_frac, _leg_f = minimiser.plot_fractions(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_frac)
341341
output.cd()
342342
if is_save_to_root_file[ObjectToSave.Canvas]:
343343
canv_frac.Write()
344344
if is_save_to_root_file[ObjectToSave.Fraction]:
345-
for _, hist in histos_frac.items():
345+
for _, hist in histos_frac.values():
346346
hist.Write()
347347
if is_save_canvas_as_macro[PlotType.Frac]:
348348
canv_frac.SaveAs(f"canv_frac_{ipt+1}.C")

‎PWGHF/D2H/Macros/cut_variation.py‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,32 @@ class CutVarMinimiser:
4646

4747
def __init__( # pylint: disable=too-many-arguments
4848
self,
49-
raw_yields=np.zeros(0),
50-
eff_prompt=np.zeros(0),
51-
eff_nonprompt=np.zeros(0),
52-
unc_raw_yields=np.zeros(0),
53-
unc_eff_prompt=np.zeros(0),
54-
unc_eff_nonprompt=np.zeros(0),
49+
raw_yields=None,
50+
eff_prompt=None,
51+
eff_nonprompt=None,
52+
unc_raw_yields=None,
53+
unc_eff_prompt=None,
54+
unc_eff_nonprompt=None,
5555
):
56+
inputs = (
57+
raw_yields,
58+
eff_prompt,
59+
eff_nonprompt,
60+
unc_raw_yields,
61+
unc_eff_prompt,
62+
unc_eff_nonprompt,
63+
)
64+
65+
if all(value is None for value in inputs):
66+
raw_yields = np.zeros(0)
67+
eff_prompt = np.zeros(0)
68+
eff_nonprompt = np.zeros(0)
69+
unc_raw_yields = np.zeros(0)
70+
unc_eff_prompt = np.zeros(0)
71+
unc_eff_nonprompt = np.zeros(0)
72+
elif any(value is None for value in inputs):
73+
raise ValueError("Either all input arrays or none must be provided.")
74+
5675
self.raw_yields = raw_yields
5776
self.eff_prompt = eff_prompt
5877
self.eff_nonprompt = eff_nonprompt

0 commit comments

Comments
 (0)