check_strict_identifier

emmet.core.mpid.check_strict_identifier(idx, allowed_prefixes=STRICT_ID_PREFIXES)

Check that an identifier is well-formed, without coercing it.

Return type:

None

Parameters:
  • idx (str | MPID | AlphaID)

  • allowed_prefixes (Iterable[str])

A strict identifier is either:
  • a bare identifier: all digits ("149") or all lowercase letters ("ft", "aaaaaaft"), or

  • a prefixed identifier "<prefix>-<body>", where <prefix> is in allowed_prefixes, the separator is "-", and <body> is as above ("mp-149", "mp-ft", "mp-aaaaaaft").

Only strings, MPIDs and AlphaIDs are accepted; other types (including integers) are rejected.

Parameters

idxstr, MPID, AlphaID

The identifier to check.

allowed_prefixesIterable[str] = STRICT_ID_PREFIXES

Prefixes permitted on a prefixed identifier.

Raises

ValueError

If the identifier is not strictly valid. The message includes the reason.