Structure Prediction Utilities Module#
Miscellaneous utilities for data manipulation.
Miscellaneous tools for data parsing.
- smact.structure_prediction.utilities.get_sign(charge: int) str[source]#
Get string representation of a number’s sign.
Args:#
charge (int): The number whose sign to derive.
Returns:#
sign (str): either ‘+’, ‘-’, or ‘’ for neutral.
- smact.structure_prediction.utilities.parse_spec(species: str) tuple[str, int][source]#
Parse a species string into its atomic symbol and oxidation state.
- Parameters:
species – the species string
- Returns:
a tuple of the atomic symbol and oxidation state
- smact.structure_prediction.utilities.unparse_spec(species: tuple[str, int], include_one: bool = True) str[source]#
Unparse a species into a string representation.
The analogue of
parse_spec().- Parameters:
species (tuple[str,int]) – A tuple of (element, signed_charge).
include_one (bool) – If True, include charge of 1 in the output if charge is 1 or -1.
Returns:#
String of {element}{absolute_charge}{sign}.
Examples:#
>>> unparse_spec(("Fe", 2)) 'Fe2+' >>> unparse_spec(("O", -2)) 'O2-'