vertebrae.utils.semantic_labels

Portable identities for semantic labels and typed report metadata.

Classes

SemanticLabelKey

Marker for a value already converted to a canonical semantic label key.

Functions

semantic_label_key(value)

Return a collision-resistant JSON object key for one semantic label.

semantic_label_catalog(values)

Build an ordered, JSON-safe catalog without importing user label classes.

semantic_label_keys(values)

Serialize a sequence of labels into stable scoring keys.

canonical_semantic_array(values)

Return a one-dimensional object array of marked semantic keys.

label_display(value, catalog)

Resolve either an original label or serialized key to reportable text.

portable_json(value)

Convert typed values to deterministic JSON without lossy str fallbacks.

validate_label_catalog(catalog)

Validate an artifact label catalog and return normalized entries.

strict_json_dumps(value)

Serialize a value under the strict JSON rules used by protocol tests.

Module Contents

class vertebrae.utils.semantic_labels.SemanticLabelKey[source]

Bases: str

Marker for a value already converted to a canonical semantic label key.

vertebrae.utils.semantic_labels.semantic_label_key(value)[source]

Return a collision-resistant JSON object key for one semantic label.

Parameters:

value (Any)

Return type:

str

vertebrae.utils.semantic_labels.semantic_label_catalog(values)[source]

Build an ordered, JSON-safe catalog without importing user label classes.

Parameters:

values (Iterable[Any])

Return type:

List[Dict[str, Any]]

vertebrae.utils.semantic_labels.semantic_label_keys(values)[source]

Serialize a sequence of labels into stable scoring keys.

Parameters:

values (Iterable[Any])

Return type:

List[str]

vertebrae.utils.semantic_labels.canonical_semantic_array(values)[source]

Return a one-dimensional object array of marked semantic keys.

Parameters:

values (Iterable[Any])

Return type:

numpy.ndarray

vertebrae.utils.semantic_labels.label_display(value, catalog)[source]

Resolve either an original label or serialized key to reportable text.

Parameters:
  • value (Any)

  • catalog (Sequence[Mapping[str, Any]])

Return type:

str

vertebrae.utils.semantic_labels.portable_json(value)[source]

Convert typed values to deterministic JSON without lossy str fallbacks.

Parameters:

value (Any)

Return type:

Any

vertebrae.utils.semantic_labels.validate_label_catalog(catalog)[source]

Validate an artifact label catalog and return normalized entries.

Parameters:

catalog (Any)

Return type:

List[Dict[str, Any]]

vertebrae.utils.semantic_labels.strict_json_dumps(value)[source]

Serialize a value under the strict JSON rules used by protocol tests.

Parameters:

value (Any)

Return type:

str