Skip to content

Commit

Permalink
Merge pull request #1287 from NNPDF/pi_fix
Browse files Browse the repository at this point in the history
Fixing plotting info labeler functions
  • Loading branch information
Zaharid committed Jun 10, 2021
2 parents 439d59c + 4da660a commit 1229126
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
7 changes: 5 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ requirements:
- swig
- cmake
- pkg-config
# See https://github.com/NNPDF/nnpdf/pull/1280
- sysroot_linux-64==2.17 # [linux]
host:
- lhapdf # with python wrapper
- sqlite
- gsl # Gsl doesn't link openblas on old debian 7
- libarchive ==3.4.2 # See https://github.com/NNPDF/nnpdf/pull/1130
- yaml-cpp
- yaml-cpp >=0.6.3
- apfel >=3 # see https://github.com/scarrazza/apfel
- python
- numpy
Expand All @@ -34,7 +36,7 @@ requirements:
- gsl
- numpy
- libarchive
- yaml-cpp
- yaml-cpp >=0.6.3
- apfel
- pkg-config
- python # requirements for validphys
Expand All @@ -61,6 +63,7 @@ test:
#Build dependencies for catch tests
- {{ compiler("cxx") }}
- {{ compiler("c") }}
- sysroot_linux-64==2.17 # [linux]
- swig ==3.0.10
- cmake

Expand Down
2 changes: 0 additions & 2 deletions conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ vp-setupfit --legacy ../nnpdfcpp/config/testconfig.yml
chi2check testconfig NNPDF31_nnlo_as_0118


#Print linkage data
conda inspect linkages -p $PREFIX $PKG_NAME
32 changes: 32 additions & 0 deletions validphys2/src/validphys/plotoptions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import pandas as pd
import numbers

from validobj import ValidationError

from reportengine.floatformatting import format_number
from reportengine.compat import yaml
from reportengine.utils import get_functions, ChainMap
Expand Down Expand Up @@ -207,6 +209,7 @@ class Scale(enum.Enum):

@dataclasses.dataclass
class PlottingOptions:
func_labels: dict = dataclasses.field(default_factory=dict)
dataset_label: typing.Optional[str] = None
experiment: typing.Optional[str] = None
nnpdf31_process: typing.Optional[str] = None
Expand All @@ -233,6 +236,31 @@ class PlottingOptions:

extra_labels: typing.Optional[typing.Mapping[str, typing.List]] = None

def parse_figure_by(self):
if self.figure_by is not None:
for el in self.figure_by:
if el in labeler_functions:
self.func_labels[el] = labeler_functions[el]

def parse_line_by(self):
if self.line_by is not None:
for el in self.line_by:
if el in labeler_functions:
self.func_labels[el] = labeler_functions[el]

def parse_x(self):
if self.x is not None and self.x not in self.all_labels:
raise ValidationError(
f"The label {self.x} is not in the set of known labels {self.all_labels}"
)


@property
def all_labels(self):
if self.extra_labels is None:
return set(default_labels)
return set(self.extra_labels.keys()).union(set(default_labels))

def __post_init__(self):
if self.kinematics_override is not None:
self.kinematics_override = transform_functions[
Expand All @@ -241,6 +269,10 @@ def __post_init__(self):
if self.result_transform is not None:
self.result_transform = result_functions[self.result_transform.name]

self.parse_figure_by()
self.parse_line_by()
self.parse_x()


@dataclasses.dataclass
class PlottingFile(PlottingOptions):
Expand Down

0 comments on commit 1229126

Please sign in to comment.