Skip to content

Commit

Permalink
use nnpdf data package directly
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Nov 23, 2024
1 parent e88a4a2 commit 454446e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ pandas = "^2.1"
rich = "^12.5.1"
click = "^8.0.4"
tomli = "^2.0.1"
nnpdf = { git = "https://github.com/NNPDF/nnpdf", optional = true}
lhapdf-management = { version = "^0.5", optional = true }
nnpdf-data = { version = "*", optional = true}

[tool.poetry.group.docs]
optional = true
Expand All @@ -51,8 +50,7 @@ setuptools = "^69.0"
optional = true

[tool.poetry.group.test.dependencies]
lhapdf-management = { version = "^0.5" }
nnpdf = { git = "https://github.com/NNPDF/nnpdf" }
nnpdf-data = "*"
pytest = "^7.1.3"
pytest-cov = "^4.0.0"
pytest-env = "^0.6.2"
Expand All @@ -65,7 +63,7 @@ ipython = "^8.0"

[tool.poetry.extras]
docs = ["sphinx", "sphinx-rtd-theme", "sphinxcontrib-bibtex"]
nnpdf = ["nnpdf", "lhapdf-management"]
nnpdf = ["nnpdf-data"]

[tool.poetry.scripts]
pineko = "pineko:command"
Expand Down
13 changes: 8 additions & 5 deletions src/pineko/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ def read_grids_from_nnpdf(dataset_name, configs=None):
return None

# Import NNPDF only if we really want it!
from nnpdf_data import legacy_to_new_map
from validphys.commondataparser import EXT
from validphys.loader import Loader
from nnpdf_data import legacy_to_new_map, path_commondata
from nnpdf_data.commondataparser import EXT, parse_new_metadata

# We only need the metadata, so this should be enough
# pass it through the legacy_to_new in case this is an old name
dataset_name, variant = legacy_to_new_map(dataset_name)
cd = Loader().check_commondata(dataset_name, variant=variant)
fks = cd.metadata.theory.FK_tables

setname, observable = dataset_name.rsplit("_", 1)
metadata_file = path_commondata / setname / "metadata.yaml"
metadata = parse_new_metadata(metadata_file, observable, variant=variant)
fks = metadata.theory.FK_tables
# Return it flat
return [f"{i}.{EXT}" for operand in fks for i in operand]

Expand Down

0 comments on commit 454446e

Please sign in to comment.