Skip to content

Commit

Permalink
added data_index for correct indexing of closure data
Browse files Browse the repository at this point in the history
  • Loading branch information
comane committed Jun 27, 2023
1 parent 6d216f6 commit fddfa77
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions validphys2/src/validphys/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
)
from validphys.convolution import PredictionsRequireCutsError, predictions
from validphys.core import PDF, DataGroupSpec, DataSetSpec, Stats
from validphys.plotoptions import get_info

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -151,6 +152,38 @@ def from_convolution(cls, pdf, posset):
return cls(stats)


def data_index(data):
"""
Given a core.DataGroupSpec instance, return pd.MultiIndex
with the following levels:
1. experiment
2. datasets
3. datapoints indices (cuts already applied to)
Parameters
----------
data: core.DataGroupSpec
Returns
-------
pd.MultiIndex
"""
tuples = []


for ds in data.datasets:

experiment = get_info(ds).experiment

for i in ds.cuts.load():
tp = (experiment, ds.name, i)
tuples.append(tp)
return pd.MultiIndex.from_tuples(tuples, names=('experiment', 'dataset', 'id'))


# TODO: finish deprecating all dependencies on this index largely in theorycovmat module
groups_data = collect("data", ("group_dataset_inputs_by_metadata",))

Expand Down

0 comments on commit fddfa77

Please sign in to comment.