Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions validphys2/src/validphys/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,31 +661,40 @@ def predictions_by_kinematics_table(results, kinematics_table_notable):
return tb

groups_each_dataset_chi2 = collect("each_dataset_chi2", ("group_dataset_inputs_by_metadata",))
groups_chi2_by_process = collect("dataset_inputs_abs_chi2_data", ("group_dataset_inputs_by_process",))
groups_each_dataset_chi2_by_process = collect("each_dataset_chi2", ("group_dataset_inputs_by_process",))

@table
def groups_chi2_table(groups_data, pdf, groups_chi2, groups_each_dataset_chi2):
"""Return a table with the chi² to the groups and each dataset in
the groups."""
the groups, grouped by metadata."""
records = []
for group, groupres, dsresults in zip(groups_data, groups_chi2, groups_each_dataset_chi2):
stats = chi2_stats(groupres)
stats["group"] = group.name
records.append(stats)
for dataset, dsres in zip(group, dsresults):
stats = chi2_stats(dsres)
stats["group"] = dataset.name
records.append(stats)
return pd.DataFrame(records)


@table
def procs_chi2_table(procs_data, pdf, procs_chi2, each_dataset_chi2):
return groups_chi2_table(procs_data, pdf, procs_chi2, each_dataset_chi2)

experiments_chi2_table = collect(
"groups_chi2_table", ("group_dataset_inputs_by_experiment",)
)

@table
def procs_chi2_table(
procs_data, pdf, groups_chi2_by_process, groups_each_dataset_chi2_by_process
):
"""Same as groups_chi2_table but by process"""
return groups_chi2_table(
procs_data,
pdf,
groups_chi2_by_process,
groups_each_dataset_chi2_by_process,
)

#procs_chi2_table = collect("groups_chi2_table", ("group_dataset_inputs_by_process",))

@check_cuts_considered
@table
def closure_shifts(experiments_index, fit, use_cuts, experiments):
Expand Down
19 changes: 15 additions & 4 deletions validphys2/src/validphys/theorycovariance/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,46 @@

from reportengine.figure import figure
from reportengine.table import table
from reportengine import collect

from validphys import plotutils
from validphys.results import groups_chi2_table

log = logging.getLogger(__name__)

abs_chi2_data_theory_dataset_by_process = collect(
"abs_chi2_data_theory_dataset", ("group_dataset_inputs_by_process",)
)


@table
def procs_chi2_table_theory(
procs_data, pdf, abs_chi2_data_theory_proc, abs_chi2_data_theory_dataset
procs_data, pdf, abs_chi2_data_theory_proc, abs_chi2_data_theory_dataset_by_process
):
"""Same as groups_chi2_table but including theory covariance matrix.
Note: we use groups_chi2_table here but provide data grouped by process."""
return groups_chi2_table(
procs_data, pdf, abs_chi2_data_theory_proc, abs_chi2_data_theory_dataset
procs_data,
pdf,
abs_chi2_data_theory_proc,
abs_chi2_data_theory_dataset_by_process,
)


@table
def procs_chi2_table_diagtheory(
procs_data, pdf, abs_chi2_data_diagtheory_proc, abs_chi2_data_diagtheory_dataset
procs_data,
pdf,
abs_chi2_data_diagtheory_proc,
abs_chi2_data_theory_dataset_by_process,
):
"""Same as groups_chi2_table but including diagonal theory covariance matrix.
Note: we use groups_chi2_table here but provide data grouped by process."""
return groups_chi2_table(
procs_data,
pdf,
abs_chi2_data_diagtheory_proc,
abs_chi2_data_diagtheory_dataset,
abs_chi2_data_theory_dataset_by_process,
)


Expand Down