BaseRealWithUnits
- class ase2sprkkr.input_parameters.test.grammar_types.basic.BaseRealWithUnits(prefix=None, postfix=None, format='', after_format=None, default_value=None, condition=None, after_convert=None, description='', min=None, max=None, nan=None)[source]
The base class for float value, which can have units append. The value is converted automatically to the base units.
Class hierarchy
Constructor
- Parameters:
prefix (str | None)
postfix (str | None)
format (str)
after_format (str | None)
default_value (Any)
condition (Callable[[Any], bool | str] | None)
after_convert (Callable[[Any], Any] | None)
min (int | None)
max (int | None)
- __init__(prefix=None, postfix=None, format='', after_format=None, default_value=None, condition=None, after_convert=None, description='', min=None, max=None, nan=None)
- Parameters:
min (int | None) – Minimal allowed value.
max (int | None) – Maximal allowed value.
prefix (str | None)
postfix (str | None)
format (str)
after_format (str | None)
default_value (Any)
condition (Callable[[Any], bool | str] | None)
after_convert (Callable[[Any], Any] | None)
- grammar_cache = {}
The grammar for units is cached
- _grammar(param_name)[source]
Token for matching strings that match a given regular expression. Defined with string specifying the regular expression in a form recognized by the stdlib Python re module. If the given regex contains named groups (defined using
(?P<name>...)
), these will be preserved as namedParseResults
.If instead of the Python stdlib
re
module you wish to use a different RE module (such as theregex
module), you can do so by building yourRegex
object with a compiled RE that was compiled usingregex
.Example:
realnum = Regex(r"[+-]?\d+\.\d*") # ref: https://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression roman = Regex(r"M{0,4}(CM|CD|D?{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})") # named fields in a regex will be returned as named results date = Regex(r'(?P<year>\d{4})-(?P<month>\d\d?)-(?P<day>\d\d?)') # the Regex class will accept re's compiled using the regex module import regex parser = pp.Regex(regex.compile(r'[0-9]'))
- grammar_name()[source]
Human readable expression of the grammar. By default, this is what is set by grammar.setName, however, sometimes is desirable to set even shorter string
- numpy_type
alias of
float
- allowed_types = (<class 'numpy.float64'>, <class 'float'>)
- datatype
alias of
float
- datatype_name = 'baserealwithunits'