Skip to content

Commit

Permalink
run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyStegeman committed Jan 7, 2025
1 parent acaac8e commit 3fa5718
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions nnpdf_data/nnpdf_data/commondata/CMS_WCHARM_13TEV/filter_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import functools
import logging
import yaml
import os

import numpy as np
import os

from sys_uncertainties import SYS_DEFINITIONS, SYS_UNC_BY_BIN
import yaml

from nnpdf_data.filter_utils.utils import prettify_float, symmetrize_errors

current_dir = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -17,6 +15,7 @@

STAT_LABEL = 'stat_uncorr_unc'


class Extractor:

def __init__(self, metadata_file, observable, mult_factor=1):
Expand All @@ -33,7 +32,7 @@ def __init__(self, metadata_file, observable, mult_factor=1):
"""

# Open metadata and select process
with open(metadata_file, 'r') as file:
with open(metadata_file) as file:
metadata = yaml.safe_load(file)
self.metadata = next(
(
Expand All @@ -48,15 +47,15 @@ def __init__(self, metadata_file, observable, mult_factor=1):

self.observable = observable
self.mult_factor = mult_factor

# Load the (only) table used for this dataset
table_id = self.metadata["tables"][0]
with open(f"{current_dir}/rawdata/{table_id}.yaml") as tab:
self.tab_dict = yaml.safe_load(tab)

def _generate_kinematics(self):
"""
The function generates the kinematics by reading and processing it from
The function generates the kinematics by reading and processing it from
the referenced table. Kinematics is processed in the format of a list of
dictionaries. The keys in each dictionaries specify the label (i.e. name)
for the kinematic variables. For this dataset, they are 'abs_eta' and 'm_W2'.
Expand Down Expand Up @@ -127,7 +126,7 @@ def _generate_sym_sys_unc(self):
It returns a list containing a dict for each bin in the absolute rapidity. The keys
in each dictionary are the names of the sources of uncertainties. The values
are dicts with keys 'shift', cotaining the shift from the symmetric prescription, and 'sym_error',
which is the (symmetrized) value of the uncertainty. Note that the shift is zero if the
which is the (symmetrized) value of the uncertainty. Note that the shift is zero if the
original source of uncertainty is already symmetric.
Note that uncertainties are given in percentage relative to the central data point
Expand Down Expand Up @@ -197,15 +196,15 @@ def generate_data(self):

# Uncertainty definitions
unc_definitions = self._build_unc_definitions()

# Loop over the bins
sys_artificial = [] # Initialize vector of artificial uncertainties
sys_artificial = [] # Initialize vector of artificial uncertainties
for data_idx, data in enumerate(central_data):
shift = 0
sys_unc_bin = symmetrized_sys_uncs[data_idx] # Dict of sys sources for the bin
sys_unc_bin = symmetrized_sys_uncs[data_idx] # Dict of sys sources for the bin

# Initialize dict of uncertainties
unc_dict = {STAT_LABEL: stat_unc[data_idx]} # Statistical uncertainty
unc_dict = {STAT_LABEL: stat_unc[data_idx]} # Statistical uncertainty

# Add shift from symmetrization
tmp = {}
Expand Down

0 comments on commit 3fa5718

Please sign in to comment.