Skip to content

Commit

Permalink
add the possibility to read integrability datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Feb 7, 2024
1 parent cee5220 commit 9ddf580
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
14 changes: 11 additions & 3 deletions validphys2/src/validphys/commondataparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def check(self):
has been read and the observable selected.
"""
# Check that the data_central is empty if and only if the dataset is a positivity set
if self.data_central is None and not self.is_positivity:
if self.data_central is None and not self.is_lagrange_multiplier:
raise ValidationError(f"Missing `data_central` field for {self.name}")

# Check that plotting.plot_x is being filled
Expand Down Expand Up @@ -384,6 +384,14 @@ def apply_variant(self, variant_name):
def is_positivity(self):
return self.setname.startswith("NNPDF_POS")

@property
def is_integrability(self):
return self.setname.startswith("NNPDF_INTEG")

@property
def is_lagrange_multiplier(self):
return self.is_positivity or self.is_integrability

@property
def path_data_central(self):
return self._parent.folder / self.data_central
Expand All @@ -396,7 +404,7 @@ def load_data_central(self):
pd.DataFrame
a dataframe containing the data
"""
if self.is_positivity:
if self.is_lagrange_multiplier:
data = np.zeros(self.ndata)
else:
datayaml = yaml.safe_load(self.path_data_central.read_text(encoding="utf-8"))
Expand All @@ -417,7 +425,7 @@ def load_uncertainties(self):
pd.DataFrame
a dataframe containing the uncertainties
"""
if self.is_positivity:
if self.is_lagrange_multiplier:
return pd.DataFrame([{}] * self.ndata, index=range(1, self.ndata + 1))

all_df = []
Expand Down
16 changes: 8 additions & 8 deletions validphys2/src/validphys/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ def check_cfactor(self, theoryID, setname, cfactors):

return tuple(cf)

def check_posset(self, theoryID, setname, postlambda):
"""Load a positivity dataset"""
def _check_lagrange_multiplier_set(self, theoryID, setname):
"""Check an integrability or positivity dataset"""
cd = self.check_commondata(setname, 'DEFAULT')
th = self.check_theoryID(theoryID)
if cd.legacy:
Expand All @@ -581,16 +581,16 @@ def check_posset(self, theoryID, setname, postlambda):
fk = self.check_fktable(theoryID, setname, [])
else:
fk, _ = self.check_fk_from_theory_metadata(cd.metadata.theory, theoryID)
return cd, fk, th

def check_posset(self, theoryID, setname, postlambda):
"""Load a positivity dataset"""
cd, fk, th = self._check_lagrange_multiplier_set(theoryID, setname)
return PositivitySetSpec(setname, cd, fk, postlambda, th)

def check_integset(self, theoryID, setname, postlambda):
"""Load an integrability dataset"""
cd = self.check_commondata(setname, 'DEFAULT')
th = self.check_theoryID(theoryID)
if th.is_pineappl():
fk, _ = self.check_fkyaml(setname, theoryID, [])
else:
fk = self.check_fktable(theoryID, setname, [])
cd, fk, th = self._check_lagrange_multiplier_set(theoryID, setname)
return IntegrabilitySetSpec(setname, cd, fk, postlambda, th)

def get_posset(self, theoryID, setname, postlambda):
Expand Down

0 comments on commit 9ddf580

Please sign in to comment.