Skip to content

Commit

Permalink
Drop Bases
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhekhorn committed Aug 1, 2023
1 parent 0ee166a commit 3e2d12a
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 236 deletions.
117 changes: 0 additions & 117 deletions src/eko/io/bases.py

This file was deleted.

8 changes: 3 additions & 5 deletions src/eko/io/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import yaml

from .. import version as vmod
from .bases import Bases
from ..interpolation import XGrid
from .dictlike import DictLike
from .paths import InternalPaths
from .types import EvolutionPoint as EPoint
Expand All @@ -34,10 +34,8 @@ class Metadata(DictLike):

origin: EPoint
"""Inital scale."""
bases: Bases
"""Manipulation information, describing the current status of the EKO (e.g.
`inputgrid` and `targetgrid`).
"""
xgrid: XGrid
"""Interpolation grid"""
# tagging information
_path: Optional[pathlib.Path] = None
"""Path to temporary dir."""
Expand Down
12 changes: 3 additions & 9 deletions src/eko/io/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from .. import interpolation
from . import exceptions, raw
from .access import AccessConfigs
from .bases import Bases
from .inventory import Inventory
from .items import Evolution, Matching, Operator, Recipe, Target
from .metadata import Metadata
Expand Down Expand Up @@ -105,20 +104,15 @@ def paths(self) -> InternalPaths:
"""Accessor for internal paths."""
return InternalPaths(self.metadata.path)

@property
def bases(self) -> Bases:
"""Bases information."""
return self.metadata.bases

@property
def xgrid(self) -> interpolation.XGrid:
"""Momentum fraction internal grid."""
return self.bases.xgrid
return self.metadata.xgrid

@xgrid.setter
def xgrid(self, value: interpolation.XGrid):
"""Set `xgrid` value."""
self.bases.xgrid = value
self.metadata.xgrid = value
self.update()

@property
Expand Down Expand Up @@ -551,7 +545,7 @@ def build(self) -> EKO:
metadata = Metadata(
_path=self.path,
origin=(self.operator.mu20, self.theory.heavy.num_flavs_init),
bases=Bases(xgrid=self.operator.xgrid),
xgrid=self.operator.xgrid,
)
InternalPaths(self.path).bootstrap(
theory=self.theory.raw,
Expand Down
12 changes: 6 additions & 6 deletions src/ekobox/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def apply_pdf_flavor(
output PDFs and their associated errors for the computed mu2grid
"""
# create pdfs
pdfs = np.zeros((len(eko.bases.inputpids), len(eko.bases.inputgrid)))
for j, pid in enumerate(eko.bases.inputpids):
pdfs = np.zeros((len(br.flavor_basis_pids), len(eko.xgrid)))
for j, pid in enumerate(br.flavor_basis_pids):
if not lhapdf_like.hasFlavor(pid):
continue
pdfs[j] = np.array(
[lhapdf_like.xfxQ2(pid, x, eko.mu20) / x for x in eko.bases.inputgrid.raw]
[lhapdf_like.xfxQ2(pid, x, eko.mu20) / x for x in eko.xgrid.raw]
)

# build output
Expand All @@ -91,11 +91,11 @@ def apply_pdf_flavor(
else:
error_final = None
out_grid[ep] = {
"pdfs": dict(zip(eko.bases.targetpids, pdf_final)),
"pdfs": dict(zip(br.flavor_basis_pids, pdf_final)),
"errors": None,
}
if error_final is not None:
out_grid[ep]["errors"] = dict(zip(eko.bases.targetpids, error_final))
out_grid[ep]["errors"] = dict(zip(br.flavor_basis_pids, error_final))

# rotate to evolution basis
if flavor_rotation is not None:
Expand All @@ -117,7 +117,7 @@ def apply_pdf_flavor(
# rotate/interpolate to target grid
if targetgrid is not None:
b = interpolation.InterpolatorDispatcher(
xgrid=eko.bases.targetgrid,
xgrid=eko.xgrid,
polynomial_degree=eko.operator_card.configs.interpolation_polynomial_degree,
mode_N=False,
)
Expand Down
83 changes: 0 additions & 83 deletions tests/eko/io/test_bases.py

This file was deleted.

6 changes: 3 additions & 3 deletions tests/eko/io/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import pytest
import yaml

from eko.io import bases, metadata, paths
from eko.io import metadata, paths


def test_metadata(tmp_path, caplog):
m = metadata.Metadata((1.0, 3), bases.Bases([0.1, 1.0]))
m = metadata.Metadata(origin=(1.0, 3), xgrid=[0.1, 1.0])
# errors
with caplog.at_level(logging.INFO):
m.update()
Expand All @@ -26,7 +26,7 @@ def test_metadata(tmp_path, caplog):
m.version = "0.0.0-a1~really1.0.0"
m.update()
# if I read back the thing should be what I set
mn = metadata.Metadata((1.0, 3), bases.Bases([0.1, 1.0]))
mn = metadata.Metadata(origin=(1.0, 3), xgrid=[0.1, 1.0])
mm = metadata.Metadata.load(tmp_path)
assert m.path == tmp_path
assert mm.version != mn.version
Expand Down
1 change: 0 additions & 1 deletion tests/eko/io/test_runcards.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from banana.data.theories import default_card as theory_card

from eko.io import runcards as rc
from eko.io.bases import Bases
from ekomark.data.operators import default_card as operator_card


Expand Down
10 changes: 6 additions & 4 deletions tests/eko/runner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import numpy as np

from eko import basis_rotation as br


def check_shapes(o, txs, ixs, theory_card, operators_card):
tpids = len(o.bases.targetpids)
ipids = len(o.bases.inputpids)
tpids = len(br.flavor_basis_pids)
ipids = len(br.flavor_basis_pids)
op_shape = (tpids, len(txs), ipids, len(ixs))

# check output = input
np.testing.assert_allclose(o.xgrid.raw, operators_card.xgrid.raw)
# targetgrid and inputgrid in the opcard are now ignored, we are testing this
np.testing.assert_allclose(
o.bases.targetgrid.raw,
o.xgrid.raw,
txs.raw,
)
np.testing.assert_allclose(o.bases.inputgrid.raw, ixs.raw)
np.testing.assert_allclose(o.xgrid.raw, ixs.raw)
np.testing.assert_allclose(o.mu20, operators_card.mu20)
# check available operators
~o.operators
Expand Down
3 changes: 2 additions & 1 deletion tests/eko/runner/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from eko import EKO
from eko import basis_rotation as br
from eko.io.items import Operator
from eko.io.runcards import OperatorCard, TheoryCard
from eko.runner import commons, recipes
Expand All @@ -21,7 +22,7 @@ def neweko(theory_card: TheoryCard, operator_card: OperatorCard, tmp_path: Path)
@pytest.fixture
def identity(neweko: EKO):
xs = len(neweko.xgrid.raw)
flavs = len(neweko.bases.pids)
flavs = len(br.flavor_basis_pids)
return Operator(operator=np.eye(xs * flavs).reshape((xs, flavs, xs, flavs)))


Expand Down
Loading

0 comments on commit 3e2d12a

Please sign in to comment.