AlphaID
- class emmet.core.mpid.AlphaID(identifier, padlen=0, prefix=None, separator='-')
Bases:
strIdentifier based on representing an integer as an alphabetical string.
- Args:
_alphabet (str) : The alphabet to use, defaults to lowercase Roman. _identifier (str) : The alphabetical string identifier. _padlen (int) : The minimum length of an identifier to pad left with zeroes. _prefix (str) : The ID prefix, ex. “mp” _separator (str) : The separator between _prefix and _identifier, ex: “-” _cut_point (int or None) : For legacy purposes, all MPIDs minted before the
transition to AlphaID will use the legacy format as mp-<int> when calling AlphaID(…).string.
Thus _cut_point, if not None, defines the maximum MPID at which the integer in AlphaID(…).string is preferred.
- Notes:
There is possibility for “obscene” strings to be used in AlphaID. For a comprehensive list of integer values of these IDs, you can import them: ``` from pathlib import Path from importlib_resources import files as import_resource_file if (Path(import_resource_file(“emmet.core”)) / “_forbidden_alpha_id.py”).exists():
from emmet.core._forbidden_alpha_id import FORBIDDEN_ALPHA_ID_VALUES
- else:
FORBIDDEN_ALPHA_ID_VALUES = set()
Or run generate_identifier_exclude_list.py in emmet-core/dev_scripts
- Parameters:
identifier (str | int | MPID)
padlen (int)
prefix (str | None)
separator (str)
- Return type:
Self
- property padded: str
Return the padded string identifier (without prefixing).
- property string: str
Legacy access to .string attr as in MPID.
- classmethod validate(_AlphaID__input_value, _)
Define pydantic validator for AlphaID.
- Return type:
- Parameters:
_AlphaID__input_value (Any)
_ (ValidationInfo)
- property parts: tuple[str, int]
Mimic the parts attribute of MPID (prefix, integer value).