Skip to content

Commit

Permalink
Merge pull request #310 from NNPDF/replace_nans
Browse files Browse the repository at this point in the history
replace NaNs in output with 0
  • Loading branch information
RoyStegeman authored Nov 15, 2024
2 parents 9f645ad + a5d9b27 commit 97491b8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/yadism/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,37 @@ def drop_cache(self):
if isinstance(obs, SF):
obs.drop_cache()

def replace_nans_with_0(self, out):
"""Replace any NaNs in output with 0.0
The small-x (i.e. large eta) limit is not addressed in LeProHQ because
the high energy limit of the polarized case is not known and that is the
main purpose of LeProHQ. As a result LeProHQ may return NaNs in the
small-x limit, which this function replaces with 0.0.
Note that the value of x where this plays a role is below the
experimental regime and thus this does not affect the description of
data, but only e.g. the grids used for the FIATLUX photon computation.
"""

out2 = copy.deepcopy(out)

# Loop through each observable in the dictionary
for observable, points in out2.items():
# Skip the keys that are not an observable
if observable not in observable_name.kinds:
continue

# Loop over the kinematic points
for point in points:
# Loop over each perturbative order
for values in point.orders.values():
# `values` is a tuple containing the computed values and the integration error
for tup in range(2):
# Set any NaN or inf values in the array to 0
values[tup][~np.isfinite(values[tup])] = 0.0
return out2

def get_result(self):
"""Compute coefficient functions grid for requested kinematic points.
Expand Down Expand Up @@ -263,6 +294,7 @@ def get_result(self):
self.console.print(f"[cyan]took {diff:.2f} s")

out = copy.deepcopy(self._output)
out = self.replace_nans_with_0(out)
return out


Expand Down

0 comments on commit 97491b8

Please sign in to comment.