Skip to content

Commit

Permalink
apply review comments: removed spurious src and unnecessary xq2 wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Jan 31, 2025
1 parent 457e80e commit 7ff2738
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
17 changes: 5 additions & 12 deletions validphys2/src/validphys/kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def describe_kinematics(commondata, titlelevel: int = 1):
cd = commondata
info = plotoptions_core.get_info(cd)
proc = cd.load_commondata().commondataproc
src = ""
titlespec = '#' * titlelevel
return f"""
{titlespec} {cd}
Expand All @@ -45,14 +44,6 @@ def describe_kinematics(commondata, titlelevel: int = 1):
* k2: {info.kinlabels[1]}
* k3: {info.kinlabels[2]}
Map:
```python
{src}
```
"""


Expand Down Expand Up @@ -166,16 +157,18 @@ def xq2map_with_cuts(commondata, cuts, group_name=None):
tuple will be empty."""
info = plotoptions_core.get_info(commondata)
kintable = plotoptions_core.kitable(commondata, info)
xq2mapper = commondata.process_type.xq2map

if cuts:
mask = cuts.load()
boolmask = np.zeros(len(kintable), dtype=bool)
boolmask[mask] = True
fitted_kintable = kintable.loc[boolmask]
masked_kitable = kintable.loc[~boolmask]
xq2fitted = plotoptions_core.get_xq2map(fitted_kintable, info)
xq2masked = plotoptions_core.get_xq2map(masked_kitable, info)
xq2fitted = xq2mapper(fitted_kintable, commondata.metadata)
xq2masked = xq2mapper(masked_kitable, commondata.metadata)
else:
xq2fitted = plotoptions_core.get_xq2map(kintable, info)
xq2fitted = xq2mapper(kintable, commondata.metadata)
xq2masked = (np.array([]), np.array([]))

return XQ2Map(info.experiment, commondata, xq2fitted, xq2masked, group_name)
Expand Down
14 changes: 0 additions & 14 deletions validphys2/src/validphys/plotoptions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,3 @@ def transform_result(cv, error, kintable, info):
newcv, newerror = apply_to_all_columns(pd.concat([df, kintable], axis=1), f)

return np.array(newcv), np.array(newerror)


def get_xq2map(kintable, info):
"""Return a tuple of (x,Q²) from the kinematic values defined in kitable
(usually obtained by calling ``kitable``) using the process type if available
Otherwise it will fallback to the legacy mode, i.e., "using machinery specified in``info``
"""
try:
return info.process_type.xq2map(kintable, info.ds_metadata)
except NotImplementedError as e:
raise NotImplementedError(
f"The process type {info.process_type} for {info.ds_metadata.name} is not implemented"
) from e

0 comments on commit 7ff2738

Please sign in to comment.