3. API Reference: yaslha¶
3.1. yaslha package¶
Package to handle SLHA-format files and data.
-
yaslha.
parse
(text, input_type='AUTO', parser=None, **kwargs)[source]¶ Parse a text to return an SLHA object.
3.2. yaslha.slha module¶
Module of SLHA object class.
-
class
yaslha.slha.
SLHA
[source]¶ Bases:
object
SLHA object, representing a SLHA-format text.
-
add_block
(obj: Union[Block, InfoBlock, Decay]) → None[source]¶ Add a block to SLHA file.
The name is automatically detected from the object.
-
__getitem__
(key: Any) → Any[source]¶ Get values of SLHA object or deeper.
SLHA[str]
andSLHA[int]
give the specified block and decay block, respectively. For ordinary blocks, further referencing is possible asSLHA[str, *key]
, while decay blocks refuse such referencing for safety.
-
3.3. yaslha.block module¶
Block-like object of SLHA data.
-
class
yaslha.block.
GenericBlock
[source]¶ Bases:
typing.Generic
Block-like object containing comments.
-
comment
¶ Give the interface to comments.
-
-
class
yaslha.block.
AbsBlock
(obj: Union[yaslha.line.BlockHeadLine, str])[source]¶ Bases:
yaslha.block.GenericBlock
,typing.Generic
Abstract class for SLHA blocks.
-
name
¶ Return the name of block (always in upper case).
-
q
¶ Return the Q value.
-
__iter__
(sort: bool = False) → Iterator[KT]¶ Return the keys.
-
-
class
yaslha.block.
Block
(obj: Union[yaslha.line.BlockHeadLine, str])[source]¶ Bases:
yaslha.block.AbsBlock
SLHA block that has one value for one key.
-
__getitem__
(key: Union[None, int, Sequence[int]]) → float[source]¶ Return the value corresponding to the key.
-
__setitem__
(key: Union[None, int, Sequence[int]], value: float) → None[source]¶ Set the value for the key.
-
update_line
(line: yaslha.line.ValueLine) → None[source]¶ Add the line to the block, overriding if exists.
-
merge
(another: Union[yaslha.block.Block, yaslha.block.InfoBlock]) → None[source]¶ Merge another block.
-
get
(*key, default: T) → Union[float, T][source]¶ Return the value for the key if exists, or default value.
-
__iter__
(sort: bool = False) → Iterator[Union[None, int, Sequence[int]]]¶ Return the keys.
-
-
class
yaslha.block.
InfoBlock
(obj: Union[yaslha.line.BlockHeadLine, str])[source]¶ Bases:
yaslha.block.AbsBlock
SLHA block that may have multiple values for one key.
-
update_line
(line: yaslha.line.InfoLine) → None[source]¶ Add the line to the block, overriding if exists.
-
append_line
(line: yaslha.line.InfoLine) → None[source]¶ Add the line, appending to the existing one if exists.
-
merge
(another: Union[yaslha.block.Block, yaslha.block.InfoBlock]) → None[source]¶ Merge another block.
-
__iter__
(sort: bool = False) → Iterator[int]¶ Return the keys.
-
-
class
yaslha.block.
Decay
(obj: Union[yaslha.line.DecayHeadLine, int])[source]¶ Bases:
yaslha.block.GenericBlock
Decay block.
-
br_normalize_threshold
= 1e-06¶
-
pid
¶ Return the pid of mother particle.
-
width
¶ Return the total width.
-
update_line
(line: yaslha.line.DecayLine) → None[source]¶ Add the line to the block, overriding if exists.
-
__iter__
(sort: bool = False) → Iterator[Sequence[int]]¶ Return the keys.
-
normalize
(force: bool = False) → None[source]¶ Normalize the branching ratios.
This method normalize all the branching ratios so that the sum becomes unity or less. In particular, if
force
is set True, they are normalized so that the sum becomes unity, regardless of the current value.If
force
is False and the sum is less than one, the branching ratio is not normalized, assuming that some decay channels are not listed. Ifforce
is False and the sum slightly exceeds the unity, the branching ratios are normalized, while if the excess is larger thanbr_normalize_threshold
,ValueError
is raised.
-
3.4. yaslha.comment module¶
Module of a class to handle comment interface.
-
class
yaslha.comment.
CommentInterface
(block: GenericBlock[KTG, CT])[source]¶ Bases:
typing.Generic
Accessor object to the comments in blocks.
-
pre
¶ Return pre-comment interface.
-
__getitem__
(key: Union[KTG, typing_extensions.Literal['head'][head]]) → Union[CT, str][source]¶ Return comment.
-
-
class
yaslha.comment.
PreCommentInterface
(block: GenericBlock[KTG, CT])[source]¶ Bases:
typing.Generic
Accessor object to the pre-line comments in blocks.
-
__getitem__
(key: Union[KTG, typing_extensions.Literal['head'][head]]) → List[str][source]¶ Return pre-line comment.
-
3.5. yaslha.line module¶
Module to describe each type of lines.
The line hierarchy is given by:
AbsLine - BlockHeadLine - DecayHeadLine - InfoLine - ValueLine
- NoIndexLine
- OneIndexLine
- TwoIndexLine
- ThreeIndexLine
- DecayLine
- CommentLine
-
class
yaslha.line.
LineOutputOption
[source]¶ Bases:
object
Class to hold all the options on dumping lines.
-
class
yaslha.line.
AbsLine
(**kwargs)[source]¶ Bases:
object
Abstract class for SLHA-line like objects.
-
output_option
= <yaslha.line.LineOutputOption object>¶
-
classmethod
pattern
() → Pattern[str][source]¶ Return a regexp pattern matching a SLHA line for the type.
-
classmethod
construct
(line: str) → Optional[LT][source]¶ Construct an object from a line if it maches the pattern.
-
-
class
yaslha.line.
BlockHeadLine
(name, q=None, comment=None)[source]¶ Bases:
yaslha.line.AbsLine
Line for block header.
-
name
¶ Return name in upper case.
-
-
class
yaslha.line.
DecayHeadLine
(pid: Union[str, int], width: Union[str, float], comment: Optional[str] = None)[source]¶ Bases:
yaslha.line.AbsLine
A line with format
('DECAY',1x,I9,3x,1P,E16.8,0P,3x,'#',1x,A)
.
-
class
yaslha.line.
InfoLine
(key, value, comment=None)[source]¶ Bases:
yaslha.line.AbsLine
Class for lines of INFO blocks.
An info-block line is given by
format(1x,I5,3x,A)
, which is not exclusive and matches other patterns. This class accept multi-lines, and thus values are List[str] and comments are multi-lined string, internally kept as List[str].
-
class
yaslha.line.
ValueLine
(key: Union[None, int, Sequence[int]], value: Union[str, float], comment: Optional[str] = None)[source]¶ Bases:
yaslha.line.AbsLine
Abstract class for value lines in ordinary blocks.
-
class
yaslha.line.
NoIndexLine
(value, comment=None)[source]¶ Bases:
yaslha.line.ValueLine
A line with
format(9x, 1P, E16.8, 0P, 3x, '#', 1x, A)
.
-
class
yaslha.line.
OneIndexLine
(i, value, comment=None)[source]¶ Bases:
yaslha.line.ValueLine
A line with
format(1x,I5,3x,1P,E16.8,0P,3x,'#',1x,A)
.
-
class
yaslha.line.
TwoIndexLine
(i1, i2, value, comment=None)[source]¶ Bases:
yaslha.line.ValueLine
A line with
format(1x,I2,1x,I2,3x,1P,E16.8,0P,3x,'#',1x,A)
.
-
class
yaslha.line.
ThreeIndexLine
(i1, i2, i3, value, comment=None)[source]¶ Bases:
yaslha.line.ValueLine
A line with
format(1x,I2,1x,I2,1x,I2,3x,1P,E16.8,0P,3x,'#',1x,A)
.
-
class
yaslha.line.
DecayLine
(br, channel, nda=None, comment=None)[source]¶ Bases:
yaslha.line.ValueLine
A decay line
(3x,1P,E16.8,0P,3x,I2,3x,N (I9,1x),2x,'#',1x,A)
.-
br
¶ Return the branching ratio.
-
-
class
yaslha.line.
CommentLine
(comment: Optional[str] = None)[source]¶ Bases:
yaslha.line.AbsLine
Comment line.
This object is prepared for compatibility and not intended to be inserted in blocks or decay-blocks; therefore dumping methods are not implemented.
3.6. yaslha.parser module¶
Parsers for SLHA package.
Parsers for SLHA-format, JSON-format, and YAML-format are provided.
3.7. yaslha.dumper module¶
Dumpers to write SLHA data in various format.
-
class
yaslha.dumper.
BlocksOrder
[source]¶ Bases:
enum.Enum
Options for block ordering.
-
DEFAULT
= 0¶
-
KEEP
= 1¶
-
ABC
= 2¶
-
-
class
yaslha.dumper.
ValuesOrder
[source]¶ Bases:
enum.Enum
Options for value ordering.
-
DEFAULT
= 0¶
-
KEEP
= 1¶
-
SORTED
= 2¶
-
-
class
yaslha.dumper.
CommentsPreserve
[source]¶ Bases:
enum.Enum
Options for comment handling.
-
NONE
= 0¶
-
TAIL
= 1¶
-
ALL
= 2¶
-
keep_line
¶ Return if to keep line-level comments.
-
keep_tail
¶ Return if to keep tail comments of value lines.
-
-
class
yaslha.dumper.
SLHADumper
(**kw)[source]¶ Bases:
yaslha.dumper.AbsDumper
A dumper class for SLHA output.
-
class
yaslha.dumper.
AbsMarshalDumper
(**kw)[source]¶ Bases:
yaslha.dumper.AbsDumper
An abstract class for dumpers handling marshaled data.
-
SCHEME_VERSION
= 3¶
-
-
class
yaslha.dumper.
YAMLDumper
(**kw)[source]¶ Bases:
yaslha.dumper.AbsMarshalDumper
A dumper for YAML output.
-
class
yaslha.dumper.
JSONDumper
(**kw)[source]¶ Bases:
yaslha.dumper.AbsMarshalDumper
A dumper for JSON output.
3.8. yaslha.script module¶
Scripts of this package.
3.9. yaslha.config module¶
Configuration handlers.
-
class
yaslha.config.
SectionWrapper
(data: configparser.SectionProxy)[source]¶ Bases:
object
A wrapper class of
configparser.SectionProxy
.
-
class
yaslha.config.
Config
[source]¶ Bases:
configparser.ConfigParser
Dictionary to store the configurations.