Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pydocstyle #208

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/yadism/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 14 additions & 2 deletions src/yadism/log.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Module controlling the log outputs."""
import logging
import os

Expand All @@ -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)
Expand Down
119 changes: 69 additions & 50 deletions src/yadism/observable_name.py
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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):
Expand All @@ -47,7 +54,7 @@ def __init__(self, name):

@property
def name(self):
"""joint name"""
"""Return joint name."""
return self.kind + "_" + self.flavor

@property
Expand All @@ -58,95 +65,107 @@ 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:
return "light"
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"]:
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -210,21 +229,21 @@ 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:
return f"m{self.flavor[0]}"

@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)
Expand Down
3 changes: 1 addition & 2 deletions src/yadism/output.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/yadism/runner.py
Original file line number Diff line number Diff line change
@@ -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``:

Expand Down
Loading
Loading