diff --git a/benchmarks/bench_fonll.py b/benchmarks/bench_fonll.py index 3a46c772..2f2381ff 100644 --- a/benchmarks/bench_fonll.py +++ b/benchmarks/bench_fonll.py @@ -4,33 +4,25 @@ import pineko -# @pytest.mark.parametrize("theoryid,is_mixed", [(400, False), (208, True)]) -# def benchmark_produce_fonll_tcards( -# tmp_path, test_files, test_configs, theoryid, is_mixed -# ): -# tcard = pineko.theory_card.load(theoryid) -# tcard_paths_list = pineko.fonll.produce_fonll_tcards(tcard, tmp_path, theoryid) -# # Check they are correct -# theorycards = [] -# for path in tcard_paths_list: -# with open(path, encoding="UTF-8") as f: -# theorycards.append(yaml.safe_load(f)) -# for num_fonll_tcard, fns, nfff, po, part in zip( -# theorycards, -# np.array(pineko.fonll.MIXED_FNS_CONFIG).transpose().tolist()[0] -# if is_mixed -# else np.array(pineko.fonll.FNS_CONFIG).transpose().tolist()[0], -# np.array(pineko.fonll.MIXED_FNS_CONFIG).transpose().tolist()[1] -# if is_mixed -# else np.array(pineko.fonll.FNS_CONFIG).transpose().tolist()[1], -# pineko.fonll.produce_ptos(tcard["FNS"], is_mixed), -# np.array(pineko.fonll.MIXED_FNS_CONFIG).transpose().tolist()[2] -# if is_mixed -# else np.array(pineko.fonll.FNS_CONFIG).transpose().tolist()[2], -# ): -# assert num_fonll_tcard["FNS"] == fns -# assert num_fonll_tcard["NfFF"] == int(nfff) -# assert ( -# num_fonll_tcard["PTO"] == po - 1 if is_mixed and fns == "FONLL-FFN0" else po -# ) -# assert num_fonll_tcard["FONLLParts"] == part + +@pytest.mark.parametrize("theoryid,is_mixed", [(400, False), (208, True)]) +def benchmark_produce_fonll_tcards( + tmp_path, test_files, test_configs, theoryid, is_mixed +): + tcard = pineko.theory_card.load(theoryid) + tcard_paths_list = pineko.fonll.dump_tcards(tcard, tmp_path, theoryid) + # Check they are correct + theorycards = [] + for path in tcard_paths_list: + with open(path, encoding="UTF-8") as f: + theorycards.append(yaml.safe_load(f)) + base_pto = pineko.fonll.FNS_BASE_PTO[tcard["FNS"]] + for num_fonll_tcard, cfg in zip( + theorycards, + pineko.fonll.MIXED_FNS_CONFIG if is_mixed else pineko.fonll.FNS_CONFIG, + ): + po = int(base_pto) + (cfg.delta_pto if is_mixed else 0) + assert num_fonll_tcard["FNS"] == cfg.scheme + assert num_fonll_tcard["NfFF"] == int(cfg.nf) + assert num_fonll_tcard["PTO"] == po - 1 if is_mixed and cfg.asy else po + assert num_fonll_tcard["FONLLParts"] == cfg.parts