Skip to content

lhapdf dependency #65

@BrunoLiegiBastonLiegi

Description

@BrunoLiegiBastonLiegi

I am having some problems running the example code in the README:

In [1]: from pdfflow import mkPDFs
   ...: import tensorflow as tf
   ...:
   ...: pdf = mkPDFs("NNPDF31_nnlo_as_0118", [0,2])
   ...: x = tf.random.uniform([10], dtype=tf.float64)
   ...: q2 = tf.random.uniform([10], dtype=tf.float64)*20 + 10
   ...: pid = tf.cast([-1,21,1], dtype=tf.int32)
   ...:
   ...: result = pdf.xfxQ2(pid, x, q2)
[ERROR] Data directory for LHAPDF not found, you can use the LHAPDF_DATA_PATH environ variable
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~/python_envs/qibo/lib/python3.12/site-packages/lhapdf_management/configuration.py:117, in _get_lhapdf_datapath(best_guess)
    116 try:
--> 117     import lhapdf
    119     return Path(lhapdf.paths()[0])

ModuleNotFoundError: No module named 'lhapdf'

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
Cell In[1], line 4
      1 from pdfflow import mkPDFs
      2 import tensorflow as tf
----> 4 pdf = mkPDFs("NNPDF31_nnlo_as_0118", [0,2])
      5 x = tf.random.uniform([10], dtype=tf.float64)
      6 q2 = tf.random.uniform([10], dtype=tf.float64)*20 + 10

File ~/python_envs/qibo/lib/python3.12/site-packages/pdfflow/pflow.py:97, in mkPDFs(fname, members, dirname)
     95 if dirname is None:
     96     try:
---> 97         dirname = find_pdf_path(fname)
     98     except ValueError as e:
     99         raise ValueError(f"mkPDFs need a directory") from e

File ~/python_envs/qibo/lib/python3.12/site-packages/pdfflow/configflow.py:109, in find_pdf_path(pdfname)
    107 if _data_path:
    108     all_paths.append(_data_path)
--> 109 all_paths.append(lhapdf_environment.datapath)
    111 # Return whatever path has the pdf inside
    112 for path in all_paths:

File ~/python_envs/qibo/lib/python3.12/site-packages/lhapdf_management/configuration.py:52, in _Environment.datapath(self)
     50 """Return the lhapdf datapath, don't populate until first used"""
     51 if self._datapath is None:
---> 52     self._datapath = _get_lhapdf_datapath()
     53 return self._datapath

File ~/python_envs/qibo/lib/python3.12/site-packages/lhapdf_management/configuration.py:127, in _get_lhapdf_datapath(best_guess)
    123     return Path(sys.prefix) / "share" / "LHAPDF"
    124 logger.error(
    125     "Data directory for LHAPDF not found, you can use the LHAPDF_DATA_PATH environ variable"
    126 )
--> 127 raise FileNotFoundError(
    128     "No LHAPDF data directory found, you can create it with `lhapdf-management update --init`"
    129 )

FileNotFoundError: No LHAPDF data directory found, you can create it with `lhapdf-management update --init`

I am running on mac under python3.12.8, is lhapdf needed to run this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions