DEFAULT_TAG_STYLE#
- scikitplot.cleanprompt.DEFAULT_TAG_STYLE = TagStyle(prefix='[', suffix=']', separator='-', uppercase_kind=True, style='placeholder', surrogates=None)[source]#
The placeholder grammar.
- Parameters:
- prefixstr, default=’[’
Opening delimiter.
- suffixstr, default=’]’
Closing delimiter.
- separatorstr, default=’-’
Separator between the category and the ordinal.
- uppercase_kindbool, default=True
Whether to upper-case the category in the rendered label.
- style{‘placeholder’, ‘surrogate’}, default=’placeholder’
What a removed value is replaced with.
placeholderrenders a bracket label;surrogatesubstitutes an invented but ordinary- looking value for the kinds that have one, falling back to a label for the rest. Seescikitplot.cleanprompt._surrogates.This belongs to the grammar rather than to the wider policy because it changes how a stand-in is spelled, and restoration checks the grammar digest before reading a vault. A vault written in one style therefore cannot be silently read as the other.
- surrogatesstr, optional
The identity (
name@version#digest16) of the custom surrogate set whose names this grammar issues. Filled in fromsurrogate_setwhen that is given; recorded in a vault, sodecodeneeds no set file. Requiresstyle='surrogate'.- surrogate_setSurrogateSet, optional
The set itself (
_surrogate_sets), needed to issue stand-ins. Not compared, not serialised: restoring reads stand-ins from the vault and needs onlysurrogates.
- Raises:
- PolicyError
If any part is empty, or if the suffix could begin inside a label and make the grammar ambiguous.
Notes
Developer notes. A non-empty
suffixis mandatory, and this is load-bearing rather than cosmetic. With a closing delimiter,[EMAIL-1]is not a prefix of[EMAIL-11], so a naive scan cannot confuse the two. Remove the suffix and ordinals above nine begin to corrupt each other. The upstream project happened to be safe here; making the suffix mandatory turns that accident into a guarantee, andtest__engine.py::test_ordinal_ten_does_not_collidekeeps it honest.Examples
>>> TagStyle().render("email", 3) '[EMAIL-3]' >>> TagStyle(prefix="<<", suffix=">>", separator="_").render("email", 3) '<<EMAIL_3>>'