castep_outputs.utilities.castep_res#
Module containing all regexes.
Module Attributes
Valid input where patterns are wanted. |
|
Floating point number. |
|
Integer number. |
|
Float or int with exponent. |
|
Exponent or bare floating point. |
|
Integer ratio. |
|
Generalised number. |
|
Floating point, integer or ratio. |
|
Three vector. |
|
Element name. |
|
CASTEP atom name with optional tag and label. |
|
Labelled CASTEP atom name. |
|
RegEx for atomic shell labels. |
|
RegEx for CASTEP table tags as in e.g. .md/.geom. |
|
Empty line RegEx |
|
CASTEP Atom RegEx with optional index. |
|
CASTEP atom followed by 3D vector. |
Functions
|
Construct a regex for matching table headers with given borders. |
|
Get components of an atom name (species, tag, label) from a spec string. |
|
Get all numbers in a string as a list. |
|
Construct a regex for extracting floats with assigned labels. |
- castep_outputs.utilities.castep_res.ATOMIC_DATA_3VEC#
CASTEP atom followed by 3D vector.
- castep_outputs.utilities.castep_res.ATOM_NAME_GRP_RE#
Labelled CASTEP atom name.
- castep_outputs.utilities.castep_res.ATOM_NAME_RE#
CASTEP atom name with optional tag and label.
- castep_outputs.utilities.castep_res.ATOM_RE#
CASTEP Atom RegEx with optional index.
- castep_outputs.utilities.castep_res.EMPTY#
Empty line RegEx
- castep_outputs.utilities.castep_res.EXPFNUMBER_RE#
Exponent or bare floating point.
- castep_outputs.utilities.castep_res.EXPNUMBER_RE#
Float or int with exponent.
- castep_outputs.utilities.castep_res.FLOAT_RAT_RE#
Floating point, integer or ratio.
- castep_outputs.utilities.castep_res.FNUMBER_RE#
Floating point number.
- castep_outputs.utilities.castep_res.INTNUMBER_RE#
Integer number.
- castep_outputs.utilities.castep_res.NUMBER_RE#
Generalised number.
- castep_outputs.utilities.castep_res.Pattern#
Valid input where patterns are wanted.
- castep_outputs.utilities.castep_res.RATIONAL_RE#
Integer ratio.
- castep_outputs.utilities.castep_res.SHELL_RE#
RegEx for atomic shell labels. E.g. 4d4.
- castep_outputs.utilities.castep_res.SPECIES_RE#
Element name.
- castep_outputs.utilities.castep_res.TAG_RE#
RegEx for CASTEP table tags as in e.g. .md/.geom.
- castep_outputs.utilities.castep_res.THREEVEC_RE#
Three vector.
- castep_outputs.utilities.castep_res.gen_table_re(content, border='\\\\s*', *, pre='', post='', whole_line=True)[source]#
Construct a regex for matching table headers with given borders.
- Parameters:
content (
str
) – RegEx capturing the content of the table.border (
str
) – RegEx capturing the characters the make up the border.pre (
str
) – RegEx matching content outside and before the table.post (
str
) – RegEx matching content outside and after the table.whole_line (
bool
) – Whether the RegExes are an exact match for the whole line.
- Returns:
RegEx pattern to match line(s).
- Return type:
Examples
RegEx for a line of “?”s
# No content, with any number of questionmarks. gen_table_re("", r"\?+")
RegEx for a separator line in a table which resembles:
+-----------------------------------+
gen_table_re("-+", "\+")
- castep_outputs.utilities.castep_res.get_atom_parts(spec)[source]#
Get components of an atom name (species, tag, label) from a spec string.
- Parameters:
spec (
str
) – String to split up.- Returns:
Dictionary detailing separate parts of atom name.
- Return type:
Examples
>>> get_atom_parts("Ar") {'species': 'Ar'} >>> get_atom_parts("Ar:tag") {'species': 'Ar', 'tag': 'tag'} >>> get_atom_parts("Ar [label]") {'species': 'Ar', 'label': 'label'} >>> get_atom_parts("Ar:tag[label]") {'species': 'Ar', 'tag': 'tag', 'label': 'label'}
- castep_outputs.utilities.castep_res.get_numbers(line)[source]#
Get all numbers in a string as a list.
- Parameters:
line (
str
) – String to search for valid numbers.- Returns:
All numbers found in line.
- Return type:
Examples
>>> get_numbers("Hello 13, my name is 3.142") ['13', '3.142']
See also
NUMBER_RE
RegEx matching numbers.
- castep_outputs.utilities.castep_res.labelled_floats(labels, counts=(None,), sep='\\\\s+?', suffix='')[source]#
Construct a regex for extracting floats with assigned labels.
- Parameters:
- Returns:
Regular expression to match floats with given labels.
- Return type:
- Raises:
NotImplementedError – If suffix and counts provided.
Examples
# Capture 3 space-separated floats with labels "x", "y", "z" labelled_floats(("x", "y", "z")) # Capture 2 colon-separated floats with labels "u", "v" labelled_floats(("u", "v"), sep=":") # Capture 3 space-separated floats under the label "val" labelled_floats(("val",), counts=(3,))