banana package

banana.register(path)[source]

Register configurations.

This function is provided for its simple heuristics for configuration file detection. The idea behind is that it can be invoked by runner scripts in the following way:

import banana
banana.register(__file__)

Thus, if it’s pointing to a file with a name different from the conventional one (see cfg.name), it is assumed that this file is in the same folder of the configuration file, that is named with the conventional name.

Parameters

path (str or os.PathLike) – a path pointing to configuration file, its parent directory, or another file in the same directory

Subpackages

Submodules

banana.cfg module

Configurations related objects.

This module contains the functions used to manage configurations. Moreover, the actual loaded configurations are stored in the module variable cfg, that is used as the source of truth for them.

banana.cfg.cfg = None

Global store for configurations

banana.cfg.detect(path=None)[source]

Search configurations file.

It searches the configuration file in the following places, sorted:

  • provided path (e.g. CLI argument)

  • current directory

  • home directory

  • user default configurations directory

  • system default configurations directory

If the path resolved is a directory (all cases but file path provided), it is assumed that the file name is that stored in the module level variable name.

Parameters

path (str ot os.PathLike) – path to a configuration file, or to a folder containing it

Returns

the resolved path

Return type

os.PathLike

Raises

FileNotFoundError – if the configuration file is not foundd in any of the places above

banana.cfg.load(path)[source]

Load configurations.

Load everything as a dictionary. Determines root from the loaded dictionary:

  • if the key root is found in the configuration file, it is treated as an absolute path, or a relative one (relative to the configuration file parent folder)

  • otherwise root is assigned to the configuration file parent folder itself

For the section “path”, all paths are converted to pathlib.Path type, and (if not absolute) they are considered to be relative to root.

No other conversion is performed.

Parameters

path (str or os.PathLike) – configurations file path

Returns

loaded configurations

Return type

dict

banana.cfg.name = 'banana.yaml'

Configurations file conventional name

banana.toy module

This module contains the Toy PDF.

It is defined at the initial scale \(Q = sqrt(2) GeV\).

banana.toy.mkPDF(_setname, _member)[source]

Factory functions for making single PDF members.

Create a new PDF with the given PDF set name and member ID.

Parameters
  • setname (type) – PDF set name.

  • member (type) – Member ID.

Returns

PDF object.

Return type

toyPDF

class banana.toy.toyPDF[source]

Bases: object

Imitates a lhapdf.PDF

alphasQ(q)[source]

Return alpha_s at q

alphasQ2(_q2)[source]

Return alpha_s at q2

hasFlavor(pid)[source]

Contains a pdf for pid?

set()[source]

Return the corresponding PDFSet

xfxQ(pid, x, Q)[source]

Get the PDF xf(x) value at (x,q) for the given PID.

Parameters
  • pid (int) – PDG parton ID.

  • x (float) – Momentum fraction.

  • Q (float) – Energy (renormalization) scale.

Returns

The value of xf(x,q).

Return type

type

xfxQ2(pid, x, _Q2)[source]

Get the PDF xf(x) value at (x,q2) for the given PID.

Parameters
  • pid (int) – PDG parton ID.

  • x (float) – Momentum fraction.

  • Q2 (float) – Squared energy (renormalization) scale.

Returns

The value of xf(x,q2).

Return type

float

class banana.toy.toyPDFSet[source]

Bases: object

Fake PDF set

name = 'ToyLH'

banana.utils module

banana.utils.lhapdf_path(newdir)[source]