diff --git a/src/yadism/__init__.py b/src/yadism/__init__.py index aa60064a..964e7bec 100644 --- a/src/yadism/__init__.py +++ b/src/yadism/__init__.py @@ -1,20 +1,30 @@ -""" -.. todo:: - docs -""" - -from . import output, version +"""Yet Another DIS Module.""" +from . import version from .runner import Runner __version__ = version.__version__ def run_yadism(theory: dict, observables: dict): - """ - .. todo:: - - decide the purpose - - implement - - docs + r"""Call yadism runner. + + Get the theory and observables description and computes the + Coefficient Functions for the requested kinematics. + + Parameters + ---------- + theory: dict + Dictionary containing the theory Parameters + observables: dict + Dictionary containing the DIS parameters such as + process description and kinematic specifications + + Returns + ------- + run_yadism: :obj:`Output` + output object containing the coefficient functions + grids + """ runner = Runner(theory, observables) return runner.get_result() diff --git a/src/yadism/log.py b/src/yadism/log.py index 5b811b15..6243a889 100644 --- a/src/yadism/log.py +++ b/src/yadism/log.py @@ -1,3 +1,4 @@ +"""Module controlling the log outputs.""" import logging import os @@ -22,8 +23,19 @@ def setup( log_to_stdout=log_to_stdout, log_file=log_file, ): - """ - Init logging + """Initialize log outputs. + + Parameters + ---------- + console: rich.console.Console + rich high level console interface + log_level: str + logging level + log_to_stdout: boolean-like + switch on/off printing on STD output + log_file: str-like + redirect output logs to file + """ logger.setLevel(log_level) ekologger.setLevel(log_level) diff --git a/src/yadism/observable_name.py b/src/yadism/observable_name.py index 70824ac4..80ecb7c5 100644 --- a/src/yadism/observable_name.py +++ b/src/yadism/observable_name.py @@ -1,3 +1,10 @@ +"""High level interface to the observable names. + +Wrap the name of the observables in order to perform operations on +them. For instance, it checks what kind of observable is being dealt +with and whether or not the given flavor is heavy. + +""" fake_kind = "??" sfs = ["F2", "FL", "F3", "g1", "gL", "g4"] # xs = ["XSreduced", "XSyreduced"] @@ -23,13 +30,13 @@ class ObservableName: - """ - Wrapper to observable names to easy split them into two parts. + r"""Wrapper to observable names to easy split them into two parts. Parameters ---------- - name : str - full observable name + name : str + full observable name + """ def __init__(self, name): @@ -47,7 +54,7 @@ def __init__(self, name): @property def name(self): - """joint name""" + """Return joint name.""" return self.kind + "_" + self.flavor @property @@ -58,75 +65,87 @@ def is_parity_violating(self): return False def __eq__(self, other): - """Test equality of kind and flavor""" + """Test equality of kind and flavor.""" return self.kind == other.kind and self.flavor == other.flavor def apply_kind(self, kind): - """ - Create new object with given kind and our flavor + r"""Create new object with given kind and our flavor. Parameters ---------- - kind : str - new kind + kind : str + new kind Returns ------- - apply_kind : type(self) - new kind and our flavor + apply_kind : type(self) + new kind and our flavor + """ return type(self)(kind + "_" + self.flavor) def __repr__(self): - """The full name is the representation""" + """Return the full representation name.""" return self.name def apply_flavor(self, flavor): - """ - Create new object with given flavor and our kind + r"""Create new object with given flavor and our kind. Parameters ---------- - flavor : str - new flavor + flavor : str + new flavor Returns ------- - apply_flavor : type(self) - our kind and new flavor + apply_flavor : type(self) + our kind and new flavor + """ return type(self)(self.kind + "_" + flavor) @property def is_heavy(self): - """ - Is it a heavy flavor? + r"""Check if the given flavor is heavy. Returns ------- - is_heavy : bool - is a heavy flavor? + is_heavy : bool + is a heavy flavor? + """ return self.flavor != "light" @property def is_raw_heavy(self): - """Is it a raw heavy flavor? i.e. charm, bottom, or, top""" + """Check if it is a raw heavy flavor. + + i.e. charm, bottom, or, top. + + """ return self.flavor in heavys @property def is_heavylight(self): - """Is it a heavylight flavor? i.e. charmlight, bottomlight, or, toplight""" + """Check if it is a heavylight flavor. + + i.e. charmlight, bottomlight, or, toplight. + + """ return self.flavor in heavylights @property def is_composed(self): - """Is it a composed flavor? i.e. total""" + """Check if it is a composed flavor. + + i.e. total. + + """ return self.flavor == "total" @property def flavor_family(self): - """Abstract flavor family name""" + """Return abstract flavor family name.""" if self.is_raw_heavy: return "heavy" if self.is_heavylight: @@ -134,19 +153,19 @@ def flavor_family(self): return self.flavor def apply_flavor_family(self): - """ - Return name with abstract flavor family name + r"""Return name with abstract flavor family name. Returns ------- - apply_flavor_family : type(self) - new ObservableName + apply_flavor_family : type(self) + new ObservableName + """ return self.apply_flavor(self.flavor_family) @property def hqnumber(self): - """Heavy quark flavor number""" + """Return Heavy quark flavor number""" if self.is_heavylight: idx = heavylights.index(self.flavor) elif self.flavor_family in ["light", "total"]: @@ -157,25 +176,25 @@ def hqnumber(self): @property def raw_flavor(self): - """underlying raw flavor""" + """Return underlying raw flavor.""" if self.flavor == "light": return self.flavor return heavys[self.hqnumber - 4] @classmethod def has_heavies(cls, names): - """ - Are there any heavy objects in names? + r"""Check if there are any heavy objects in names. Parameters ---------- - names : list(str) - names to check + names : list(str) + names to check Returns ------- - has_heavies : bool - are there heavy obs in names? + has_heavies : bool + are there heavy obs in names? + """ for n in names: if not cls.is_valid(n): @@ -187,18 +206,18 @@ def has_heavies(cls, names): @classmethod def has_lights(cls, names): - """ - Are there any light objects in names? + r"""Check if there are any light objects in names. Parameters ---------- - names : list(str) - names to check + names : list(str) + names to check Returns ------- - has_lights : bool - are there light obs in names? + has_lights : bool + are there light obs in names? + """ for n in names: if not cls.is_valid(n): @@ -210,7 +229,7 @@ def has_lights(cls, names): @property def mass_label(self): - """Mass label in the theory runcard""" + """Add mass label in the theory runcard.""" if self.flavor == "light": return None else: @@ -218,13 +237,13 @@ def mass_label(self): @classmethod def is_valid(cls, name): - """ - Tests whether the name is a valid observable name + r"""Test whether the name is a valid observable name. Returns ------- - is_valid : bool - is valid name? + is_valid : bool + is valid name? + """ try: cls(name) diff --git a/src/yadism/output.py b/src/yadism/output.py index ab80b6fe..b07b0139 100644 --- a/src/yadism/output.py +++ b/src/yadism/output.py @@ -1,5 +1,4 @@ -""" -Output related utilities. +"""Output related utilities. For the main output (that is the computed |PDF| independent |DIS| operator) three outputs are provided: diff --git a/src/yadism/runner.py b/src/yadism/runner.py index 02c11f26..c6f9e728 100644 --- a/src/yadism/runner.py +++ b/src/yadism/runner.py @@ -1,4 +1,4 @@ -"""This module contains the main loop for the DIS calculations. +r"""This module contains the main loop for the DIS calculations. There are two ways of using ``yadism``: diff --git a/src/yadism/sf.py b/src/yadism/sf.py index f9758486..549e8dcd 100644 --- a/src/yadism/sf.py +++ b/src/yadism/sf.py @@ -1,8 +1,8 @@ -""" -Defines the :py:class:`StructureFunction` class. +"""High-level interface to Structure Function. .. todo:: refer to the sf-esf overview + """ import logging @@ -13,8 +13,7 @@ class StructureFunction: - """ - Represents an abstract structure function. + r"""Represent an abstract structure function. This class acts as an intermediate handler between the :py:class:`Runner` exposed to the outside and the :py:class:`EvaluatedStructureFunction` @@ -22,10 +21,11 @@ class StructureFunction: Parameters ---------- - obs_name : ObservableName - name - runner : yadism.runner.Runner - parent reference + obs_name : ObservableName + name + runner : yadism.runner.Runner + parent reference + """ def __init__(self, obs_name, runner): @@ -43,13 +43,13 @@ def __len__(self): return len(self.esfs) def load(self, kinematic_configs): - """ - Loads all kinematic configurations from the run card. + r"""Load all kinematic configurations from the run card. Parameters ---------- kinematic_configs : list(dict) run card input + """ self.esfs = [] # iterate F* configurations @@ -57,8 +57,7 @@ def load(self, kinematic_configs): self.esfs.append(self.get_esf(self.obs_name, kinematics, use_raw=False)) def get_esf(self, obs_name, kinematics, *args, use_raw=True, force_local=False): - """ - Returns a :py:class:`EvaluatedStructureFunction` instance. + """Return a :py:class:`EvaluatedStructureFunction` instance. This wrappers allows @@ -70,19 +69,20 @@ def get_esf(self, obs_name, kinematics, *args, use_raw=True, force_local=False): Parameters ---------- - obs_name : .observable_name.ObservableName - structure function name - kinematics : dict - kinematic configuration - args : any - further arguments passed down to the instance - use_raw : bool - eventually use the ESFTMC? (or just the uncorrected one) + obs_name : .observable_name.ObservableName + structure function name + kinematics : dict + kinematic configuration + args : any + further arguments passed down to the instance + use_raw : bool + eventually use the ESFTMC? (or just the uncorrected one) Returns ------- - obj : EvaluatedStructureFunction - created object + obj : EvaluatedStructureFunction + created object + """ # TODO rethink and refactor method - only used by TMC # TODO remove force_local @@ -119,16 +119,17 @@ def get_esf(self, obs_name, kinematics, *args, use_raw=True, force_local=False): @property def elements(self): + """Collect the computed observables.""" return self.esfs def get_result(self): - """ - Collects the results from all childrens. + r"""Collect the results from all childrens. Returns ------- - output : list(ESFResult) - all children outputs + output : list(ESFResult) + all children outputs + """ return list(elem.get_result() for elem in self.elements) diff --git a/src/yadism/version.py b/src/yadism/version.py index 6c8e6b97..d65f2d1d 100644 --- a/src/yadism/version.py +++ b/src/yadism/version.py @@ -1 +1,2 @@ +"""Placeholder for versionning.""" __version__ = "0.0.0" diff --git a/src/yadism/xs.py b/src/yadism/xs.py index ce219ee7..d8405d55 100644 --- a/src/yadism/xs.py +++ b/src/yadism/xs.py @@ -1,3 +1,9 @@ +"""Module that computes a physical observable. + +The observable could be structure functions or some linear +combination of them. + +""" import logging from .esf import exs @@ -6,8 +12,7 @@ class CrossSection: - """ - Represents an abstract structure function. + r"""Represents an abstract structure function. This class acts as an intermediate handler between the :py:class:`Runner` exposed to the outside and the :py:class:`EvaluatedStructureFunction` @@ -15,10 +20,10 @@ class CrossSection: Parameters ---------- - obs_name : ObservableName - name - runner : yadism.runner.Runner - parent reference + obs_name : ObservableName + name + runner : yadism.runner.Runner + parent reference """ def __init__(self, obs_name, runner): @@ -36,16 +41,17 @@ def __len__(self): @property def elements(self): + """Collect the evaluated observable.""" return self.exss def load(self, kinematic_configs): - """ - Loads all kinematic configurations from the run card. + r"""Load all kinematic configurations from the run card. Parameters ---------- - kinematic_configs : list(dict) - run card input + kinematic_configs : list(dict) + run card input + """ self.exss = [] for kinematics in kinematic_configs: @@ -56,15 +62,30 @@ def load(self, kinematic_configs): ) def get_esf(self, obs_name, kin): + r"""Get the observable in question for given kinematics. + + Parameters + ---------- + obs_name: str + name of the observable + kin: dict + contains the kinematic specs + + Returns + ------- + get_sf: + observable evaluated on some kinematics + + """ return self.runner.get_sf(obs_name).get_esf(obs_name, kin, use_raw=False) def get_result(self): - """ - Collects the results from all childrens. + r"""Collect the results from all childrens. Returns ------- - output : list(ESFResult) - all children outputs + output : list(ESFResult) + all children outputs + """ return list(elem.get_result() for elem in self.elements)