Skip to content

Commit

Permalink
only return paths that do exist
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Aug 5, 2024
1 parent 0017ef1 commit 2076f15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions validphys2/src/validphys/lhaindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import glob
import os
import os.path as osp
from pathlib import Path
import re

from reportengine.compat import yaml
Expand Down Expand Up @@ -130,6 +131,12 @@ def parse_info(name):


def get_lha_datapath():
"""Return an existing datapath from LHAPDF, starting from the end.
If no path is found to exist, recover the old behaviour and returns the last path.
"""
for lhapath in lhapdf.paths()[::-1]:
if Path(lhapath).exists():
return lhapath
return lhapdf.paths()[-1]


Expand Down
3 changes: 2 additions & 1 deletion validphys2/src/validphys/lhapdf_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
`lhapdf-management` and `pdfflow`
which cover all the features of LHAPDF used during the fit (and likely most of validphys)
"""

from functools import cached_property

import numpy as np
Expand Down Expand Up @@ -86,7 +87,7 @@ def xfxQ(self, a, b, c=None):

if isinstance(a, int):
return ret_dict.get(a, zeros)
return [ret_dict.get(i, zeros) for i in a]
return np.array([ret_dict.get(i, zeros) for i in a]).T

def xfxQ2(self, a, b, c=None):
"""Wrapper for LHAPDF xfxQ2 function, like xfxQ for Q2"""
Expand Down

0 comments on commit 2076f15

Please sign in to comment.