basics¶
This submodule implements the most basic objects used throughout the package,
ranging from Union to customisable indices via CustomIndex and IntIndex.
The latter then have to be tracked for custom
Block implementations by use of the
decorators
@indices or @defaultIndices.
- dim¶
Specifies the dimensions assumed in spacetime. Any change may require some adjustment of
rotPlanesas well as anyBlocktransformation properties.- Type:
- rotPlanes¶
Spacetime indices associated to the different rotational planes.
- enum CustomIndex(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
EnumCustom-labelled indices.
Allows the definition of indices with custom string-valued labels. Uses Python Enum as underlying object to assign integer-values to those labels.
- enum IntIndex(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
IntEnumRepresents an integer-valued index, directly inherited from
IntEnumwithout modification. Allows to define a range of values allowed for the indices.
- class Union¶
Bases:
objectCollection of elements x with an associated label str(x) assumed to be a unique identifier. Based on this label, adding a new element is vetoed if the label is already present.
- add(x, copy=True)¶
Adds element x to the collection if not already present according to its string-representation.
- defaultIndices(cls)¶
Assumes the default behaviour for indices, i.e., the custom Block.__init__ is expected to have as arguments all the indices plus one called factor referring to the overall factor. The arguments belonging to indices must be named according to the class-member used to store the indices and must be type-hinted using the explicit type for each index.
- indices(suffix: str | None, **kwargs: dict[str, type])¶
Sets the class attributes
cls.__indexType__ # tuple[type] referring to the type of the index cls.__indexName__ # tuple[str] referring to the index label cls.__suffix__ # str representation of indices etc.
Those are necessary to turn custom
Blockimplementations into regular expressions. suffix is expected to carry as many %s as there are indices.- Parameters:
suffix (str|) – String representation of the trailing indices etc. used during calls to
Block.__str__as well as parsing from string representation via regular expressions. IfNone, the default form is chosen for __suffix__.kwargs (dict[str,type]) – Collection of member-names of the current Block implementation referring to indices and their associated type. From Python 3.10 onwards dictionaries have a frozen order. Make sure to use an ordering of the indices that matches the arguments in the function signature.
- Returns:
Handler acting on the actual class type.
- Return type:
function
- Raises:
AssertionError – If the number of %s in suffix does not match the number of indices.
- massDim(md: int | Fraction)¶
Allows to assign a non-zero mass dimension to an instance of
Blockthrough use of a decorator @massDim(…) in front of the class implementation. Mass-dimensions are expected to be non-rational numbers.- Parameters:
md (int | Fraction) – Mass-dimension that should be assigned to the current implementation of
Block.- Returns:
cls – The initial Block implementation but with a mass-dimension set.
- Return type:
- Raises:
AssertionError – If the chosen mass-dimension is not a non-negative integer.