Skip to content

Commit 0dd7e0a

Browse files
committed
Removing deprecated functions + clean up
1 parent 706de6c commit 0dd7e0a

File tree

2 files changed

+34
-45
lines changed

2 files changed

+34
-45
lines changed

validphys2/src/validphys/theorycovariance/construction.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Tools for constructing theory covariance matrices and computing their chi2s.
44
"""
55

6-
from collections import defaultdict, namedtuple
6+
from collections import defaultdict
77
import dataclasses
88
import logging
99

@@ -531,7 +531,9 @@ def fromfile_covmat(covmatpath, groups_data_by_process, procs_index):
531531

532532

533533
@table
534-
def user_covmat(groups_data_by_process, procs_index, loaded_user_covmat_path, mult_factor_user_covmat):
534+
def user_covmat(
535+
groups_data_by_process, procs_index, loaded_user_covmat_path, mult_factor_user_covmat
536+
):
535537
"""
536538
General theory covariance matrix provided by the user.
537539
Useful for testing the impact of externally produced
@@ -541,7 +543,9 @@ def user_covmat(groups_data_by_process, procs_index, loaded_user_covmat_path, mu
541543
``user_covmat_path`` in ``theorycovmatconfig`` in the
542544
runcard. For more information see documentation.
543545
"""
544-
return mult_factor_user_covmat * fromfile_covmat(loaded_user_covmat_path, groups_data_by_process, procs_index)
546+
return mult_factor_user_covmat * fromfile_covmat(
547+
loaded_user_covmat_path, groups_data_by_process, procs_index
548+
)
545549

546550

547551
@table

validphys2/src/validphys/theorycovariance/higher_twist_functions.py

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ def linear_bin_function(
9999

100100

101101
def dis_pc_func(
102-
delta_h: npt.ArrayLike,
103-
nodes: npt.ArrayLike,
104-
x: npt.ArrayLike,
105-
Q2: npt.ArrayLike,
102+
delta_h: npt.ArrayLike, nodes: npt.ArrayLike, x: npt.ArrayLike, Q2: npt.ArrayLike
106103
) -> npt.ArrayLike:
107104
"""
108105
This function builds the functional form of the power corrections for DIS-like processes.
@@ -132,10 +129,7 @@ def dis_pc_func(
132129

133130

134131
def jets_pc_func(
135-
delta_h: npt.ArrayLike,
136-
nodes: npt.ArrayLike,
137-
pT: npt.ArrayLike,
138-
rap: npt.ArrayLike,
132+
delta_h: npt.ArrayLike, nodes: npt.ArrayLike, pT: npt.ArrayLike, rap: npt.ArrayLike
139133
) -> npt.ArrayLike:
140134
"""
141135
Same as `dis_pc_func`, but for jet data. Here, the kinematic pair consists of the rapidity
@@ -161,30 +155,6 @@ def jets_pc_func(
161155
return PC
162156

163157

164-
# def jet_single_par(delta_h: float, pT: npt.ArrayLike, rap: npt.ArrayLike) -> npt.ArrayLike:
165-
# ret = [delta_h for _ in range(rap.size)]
166-
# return np.array(ret) / pT
167-
168-
# def mult_jet_pc_single_par(dataset_sp, pdf, pc_nodes, pT, rap, pc_func_type: str = "step"):
169-
# """
170-
# As mult_jet_pc, but with one single shift for all rapidity bins.
171-
172-
# This function is meant to be for development purposes only. It will either substitute
173-
# mult_jet_pc or be deleted in the future."""
174-
# cuts = dataset_sp.cuts
175-
# (fkspec,) = dataset_sp.fkspecs
176-
# fk = fkspec.load_with_cuts(cuts)
177-
# xsec = central_fk_predictions(fk, pdf)
178-
179-
# def func(y_values):
180-
# assert y_values.size == 1
181-
# ret = [y_values[0] for _ in range(rap.size)]
182-
# ret = np.array(ret) / pT
183-
# return np.multiply(ret, xsec.to_numpy()[:, 0])
184-
185-
# return func
186-
187-
188158
def mult_dis_pc(nodes, x, q2, dataset_sp, pdf):
189159
"""
190160
Returns the function that computes the shift to observables due to
@@ -272,6 +242,7 @@ def func(y_values_p, y_values_d):
272242

273243
return func
274244

245+
275246
def mult_jet_pc(nodes, pT, rap, dataset_sp, pdf):
276247
"""
277248
As `mult_dis_pc`, but for jet data. The power corrections are defined as
@@ -295,6 +266,7 @@ def func(y_values):
295266

296267
return func
297268

269+
298270
def construct_pars_combs(parameters_dict):
299271
"""Construct the combination of parameters (the ones that parametrize the power
300272
corrections) used to compute the shifts.
@@ -335,6 +307,7 @@ def construct_pars_combs(parameters_dict):
335307

336308
return combinations
337309

310+
338311
def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict):
339312
"""
340313
Computes the shifts due to power corrections for a single dataset given
@@ -374,7 +347,9 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict):
374347
if exp_name == "NMC_NC_NOTFIXED_EM-F2":
375348
pc_func_ratio = mult_dis_ratio_pc(f2_p_nodes, f2_d_nodes, x, q2, dataset_sp, pdf)
376349
for pars_pc in pars_combs:
377-
deltas[pars_pc['label']] = pc_func_ratio(pars_pc['comb']['f2p'], pars_pc['comb']['f2d'])
350+
deltas[pars_pc['label']] = pc_func_ratio(
351+
pars_pc['comb']['f2p'], pars_pc['comb']['f2d']
352+
)
378353

379354
# F2 proton traget
380355
elif exp_name in F2P_exps:
@@ -390,9 +365,8 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict):
390365

391366
# EMC
392367
elif exp_name.startswith('EMC_NC_250GEV'):
393-
raise NotImplementedError(
394-
f"The {process_type} observable for {exp_name} "
395-
"has not been implemented."
368+
raise NotImplementedError(
369+
f"The {process_type} observable for {exp_name} " "has not been implemented."
396370
)
397371

398372
# HERA NC xsec
@@ -409,7 +383,7 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict):
409383

410384
# NuTeV
411385
elif exp_name.startswith('NUTEV_CC'):
412-
pc_func = mult_dis_pc(dis_cc_nodes , x, q2, dataset_sp, pdf)
386+
pc_func = mult_dis_pc(dis_cc_nodes, x, q2, dataset_sp, pdf)
413387
for pars_pc in pars_combs:
414388
deltas[pars_pc['label']] = pc_func(pars_pc['comb']['dis_cc'])
415389

@@ -434,10 +408,13 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict):
434408
deltas[pars_pc['label']] = pc_func(pars_pc['comb']['Hj'])
435409

436410
elif process_type == 'DIJET':
437-
438411

439412
if dataset_sp.commondata.metadata.experiment == 'ATLAS':
440-
pc_jet_nodes = pc_dict["H2j_ATLAS"]['nodes'] if pc_dict.get("H2j_ATLAS") else pc_dict["H2j"]['nodes']
413+
pc_jet_nodes = (
414+
pc_dict["H2j_ATLAS"]['nodes']
415+
if pc_dict.get("H2j_ATLAS")
416+
else pc_dict["H2j"]['nodes']
417+
)
441418
eta_star = (
442419
dataset_sp.commondata.metadata.load_kinematics()['ystar']
443420
.to_numpy()
@@ -450,10 +427,16 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict):
450427
)
451428
pc_func = mult_jet_pc(pc_jet_nodes, m_jj, eta_star, dataset_sp, pdf)
452429
for pars_pc in pars_combs:
453-
deltas[pars_pc['label']] = pc_func(pars_pc['comb']['H2j_ATLAS'] if pc_dict.get("H2j_ATLAS") else pars_pc['comb']['H2j'])
430+
deltas[pars_pc['label']] = pc_func(
431+
pars_pc['comb']['H2j_ATLAS']
432+
if pc_dict.get("H2j_ATLAS")
433+
else pars_pc['comb']['H2j']
434+
)
454435

455436
elif dataset_sp.commondata.metadata.experiment == 'CMS':
456-
pc_jet_nodes = pc_dict["H2j_CMS"]['nodes'] if pc_dict.get("H2j_CMS") else pc_dict["H2j"]['nodes']
437+
pc_jet_nodes = (
438+
pc_dict["H2j_CMS"]['nodes'] if pc_dict.get("H2j_CMS") else pc_dict["H2j"]['nodes']
439+
)
457440
eta_diff = (
458441
dataset_sp.commondata.metadata.load_kinematics()['ydiff']
459442
.to_numpy()
@@ -466,7 +449,9 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict):
466449
)
467450
pc_func = mult_jet_pc(pc_jet_nodes, m_jj, eta_diff, dataset_sp, pdf)
468451
for pars_pc in pars_combs:
469-
deltas[pars_pc['label']] = pc_func(pars_pc['comb']['H2j_CMS'] if pc_dict.get("H2j_CMS") else pars_pc['comb']['H2j'])
452+
deltas[pars_pc['label']] = pc_func(
453+
pars_pc['comb']['H2j_CMS'] if pc_dict.get("H2j_CMS") else pars_pc['comb']['H2j']
454+
)
470455

471456
else:
472457
raise ValueError(

0 commit comments

Comments
 (0)