@@ -456,13 +456,10 @@ def total_theory_covmat(theory_covmat_custom, user_covmat):
456456 return theory_covmat_custom + user_covmat
457457
458458
459- def theory_covmat_custom_fitting (theory_covmat_custom_per_prescription , procs_index_matched ):
460- """theory_covmat_custom_per_prescription but reindexed so the order of the datasets matches
461- those in the experiment covmat so they are aligned when fitting."""
462- df = theory_covmat_custom_per_prescription .reindex (procs_index_matched ).T .reindex (
463- procs_index_matched
464- )
465- return df
459+ def _reindex_covmat_to_fitting_order (covmat , index ):
460+ """Reindex a covmat DataFrame so the dataset ordering matches the experiment
461+ covmat (the grouped/runcard order) used when fitting."""
462+ return covmat .reindex (index ).T .reindex (index )
466463
467464
468465theory_covmats_fitting = collect (theory_covmat_custom_per_prescription , ("point_prescriptions" ,))
@@ -474,16 +471,22 @@ def theory_covmat_custom(theory_covmats_fitting):
474471 return sum (theory_covmats_fitting )
475472
476473
474+ def theory_covmat_custom_fitting (theory_covmat_custom , procs_index_matched ):
475+ """theory_covmat_custom (summed over all point prescriptions) reindexed so the
476+ dataset ordering matches the experiment covmat for alignment when fitting."""
477+ return _reindex_covmat_to_fitting_order (theory_covmat_custom , procs_index_matched )
478+
479+
477480def total_theory_covmat_fitting (total_theory_covmat , procs_index_matched ):
478481 """total_theory_covmat but reindexed so the order of the datasets matches
479482 those in the experiment covmat so they are aligned when fitting."""
480- return theory_covmat_custom_fitting (total_theory_covmat , procs_index_matched )
483+ return _reindex_covmat_to_fitting_order (total_theory_covmat , procs_index_matched )
481484
482485
483486def user_covmat_fitting (user_covmat , procs_index_matched ):
484487 """user_covmat but reindexed so the order of the datasets matches
485488 those in the experiment covmat so they are aligned when fitting."""
486- return theory_covmat_custom_fitting (user_covmat , procs_index_matched )
489+ return _reindex_covmat_to_fitting_order (user_covmat , procs_index_matched )
487490
488491
489492def procs_index_matched (groups_index , procs_index ):
0 commit comments