httk.atomistic.models.formula.notation¶
The one home of httk’s reduced/anonymous formula notation.
Functions¶
|
Return the unbounded OPTIMADE anonymous symbol for a zero-based index. |
|
Return the least common integer coefficients for exact elemental ratios. |
|
Render element symbols and reduced integer coefficients in the given order. |
|
Render descending-sorted integer counts using OPTIMADE anonymous symbols. |
|
Parse a strictly canonical reduced OPTIMADE chemical formula. |
|
Parse a strictly canonical OPTIMADE anonymous chemical formula. |
|
Return canonical reduced coefficients, or |
|
Return canonical anonymous coefficients, or |
Module Contents¶
- httk.atomistic.models.formula.notation.anonymous_symbol(index)[source]¶
Return the unbounded OPTIMADE anonymous symbol for a zero-based index.
- Parameters:
index (int) – The non-negative zero-based symbol index.
- Returns:
The generated anonymous symbol.
- Raises:
ValueError – If
indexis not a non-negative integer.- Return type:
- httk.atomistic.models.formula.notation.reduced_coefficients(ratios)[source]¶
Return the least common integer coefficients for exact elemental ratios.
- Parameters:
ratios (collections.abc.Sequence[fractions.Fraction]) – The exact elemental ratios in their desired output order.
- Returns:
The reduced integer coefficients, or
Nonefor an empty sequence.- Return type:
- httk.atomistic.models.formula.notation.render_reduced(coefficients)[source]¶
Render element symbols and reduced integer coefficients in the given order.
- Parameters:
coefficients (collections.abc.Sequence[tuple[str, int]]) – The element and coefficient pairs to render.
- Returns:
The canonical reduced formula text.
- Return type:
- httk.atomistic.models.formula.notation.render_anonymous(counts)[source]¶
Render descending-sorted integer counts using OPTIMADE anonymous symbols.
- Parameters:
counts (collections.abc.Sequence[int]) – The coefficients in descending order.
- Returns:
The canonical anonymous formula text.
- Return type:
- httk.atomistic.models.formula.notation.parse_reduced_formula(text)[source]¶
Parse a strictly canonical reduced OPTIMADE chemical formula.
The reduced and anonymous grammars are disjoint by construction: an anonymous label may have an arbitrary lowercase tail, while an element symbol has at most one.
- httk.atomistic.models.formula.notation.parse_anonymous_formula(text)[source]¶
Parse a strictly canonical OPTIMADE anonymous chemical formula.
- httk.atomistic.models.formula.notation.try_parse_reduced(text)[source]¶
Return canonical reduced coefficients, or
Nonewhen text is not one.