Skip to content

Commit

Permalink
format a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyStegeman authored and achiefa committed Jan 8, 2025
1 parent 54bda12 commit 3725aa4
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 333 deletions.
9 changes: 6 additions & 3 deletions validphys2/src/validphys/commondata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
:py:mod:`validphys.coredata`
"""

import functools

from reportengine import collect
from validphys.commondataparser import load_commondata
import functools


@functools.lru_cache
def loaded_commondata_with_cuts(commondata, cuts):
Expand Down Expand Up @@ -37,5 +40,5 @@ def loaded_commondata_with_cuts(commondata, cuts):
)

groups_dataset_inputs_loaded_cd_with_cuts_byprocess = collect(
"loaded_commondata_with_cuts", ("group_dataset_inputs_by_process", "data")
)
"loaded_commondata_with_cuts", ("group_dataset_inputs_by_process", "data")
)
11 changes: 4 additions & 7 deletions validphys2/src/validphys/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,7 @@ def produce_loaded_user_covmat_path(self, user_covmat_path: str = ""):
l = self.loader
fileloc = l.check_vp_output_file(user_covmat_path)
return fileloc



@configparser.explicit_node
def produce_covmat_custom(self, use_ht_uncertainties: bool = False):
if use_ht_uncertainties:
Expand Down Expand Up @@ -1225,15 +1224,13 @@ def res(*args, **kwargs):
# Set this to get the same filename regardless of the action.
res.__name__ = "theory_covmat"
return res



@configparser.explicit_node
def produce_combine_by_type_custom(self, use_ht_uncertainties: bool = False):
if use_ht_uncertainties:
return validphys.theorycovariance.construction.combine_by_type_ht
return validphys.theorycovariance.construction.combine_by_type


def produce_fitthcovmat(
self, use_thcovmat_if_present: bool = False, fit: (str, type(None)) = None
):
Expand Down Expand Up @@ -1779,9 +1776,9 @@ def produce_filter_data(self, fakedata: bool = False, theorycovmatconfig=None):
if not fakedata:
return validphys.filters.filter_real_data
else:
#if theorycovmatconfig is not None and theorycovmatconfig.get(
# if theorycovmatconfig is not None and theorycovmatconfig.get(
# "use_thcovmat_in_sampling"
#):
# ):
# # NOTE: By the time we run theory covmat closure tests,
# # hopefully the generation of pseudodata will be done in python.
# raise ConfigError(
Expand Down
16 changes: 7 additions & 9 deletions validphys2/src/validphys/dataplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Plots of relations between data PDFs and fits.
"""

from __future__ import generator_stop

from collections import defaultdict
from collections.abc import Sequence
import itertools
Expand All @@ -28,7 +26,7 @@
from validphys.coredata import KIN_NAMES
from validphys.plotoptions.core import get_info, kitable, transform_result
from validphys.results import chi2_stat_labels, chi2_stats
from validphys.sumrules import POL_LIMS, partial_polarized_sum_rules
from validphys.sumrules import POL_LIMS
from validphys.utils import sane_groupby_iter, scale_from_grid, split_ranges

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -301,9 +299,7 @@ def _plot_fancy_impl(
min_vals = []
max_vals = []
fig, ax = plotutils.subplots()
ax.set_title(
"{} {}".format(info.dataset_label, info.group_label(samefig_vals, info.figure_by))
)
ax.set_title(f"{info.dataset_label} {info.group_label(samefig_vals, info.figure_by)}")

lineby = sane_groupby_iter(fig_data, info.line_by)

Expand Down Expand Up @@ -1494,7 +1490,7 @@ def next_options():
# if group is None then make sure that shows on legend.
key = str(group)
elif marker_by == "kinematics":
key = None
key = None
else:
raise ValueError('Unknown marker_by value')

Expand Down Expand Up @@ -1526,8 +1522,10 @@ def next_options():
# This is to get the label key
coords = [], []
if marker_by == "kinematics":
ht_magnitude = np.concatenate( cvdict[key]) / (coords[1] * (1 - coords[0]) )
out = ax.scatter(*coords, marker='.', c=ht_magnitude, cmap="viridis", norm=mcolors.LogNorm())
ht_magnitude = np.concatenate(cvdict[key]) / (coords[1] * (1 - coords[0]))
out = ax.scatter(
*coords, marker='.', c=ht_magnitude, cmap="viridis", norm=mcolors.LogNorm()
)
clb = fig.colorbar(out)
clb.ax.set_title(r'$F_\mathrm{exp}\frac{1}{Q^2(1-x)}$')
ax.plot(*coords, label=key, markeredgewidth=1, markeredgecolor=None, **key_options[key])
Expand Down
37 changes: 22 additions & 15 deletions validphys2/src/validphys/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,29 @@ def group_kin_table_no_table(groups_data, groups_index):
"""Generate a table containing the kinematics and the process_type."""
result_records = []
for group_data in groups_data:
group_cd = group_data.load_commondata()
cd = np.concatenate(
[group_cd[i].commondata_table[['kin1','kin2','kin3','process']] for i in range(len(group_cd))],
axis=0
)
for index, dataset in enumerate(cd):
try:
process_name = dataset[3].name
except AttributeError:
process_name = dataset[3]
result_records.append(
dict([("kin_1", dataset[0]),
("kin_2", dataset[1]),
("kin_3", dataset[2]),
("process_type", process_name)])
group_cd = group_data.load_commondata()
cd = np.concatenate(
[
group_cd[i].commondata_table[['kin1', 'kin2', 'kin3', 'process']]
for i in range(len(group_cd))
],
axis=0,
)
for index, dataset in enumerate(cd):
try:
process_name = dataset[3].name
except AttributeError:
process_name = dataset[3]
result_records.append(
dict(
[
("kin_1", dataset[0]),
("kin_2", dataset[1]),
("kin_3", dataset[2]),
("process_type", process_name),
]
)
)

if not result_records:
log.warning("Empty records for group results")
Expand Down
Loading

0 comments on commit 3725aa4

Please sign in to comment.