ts_shape.eventlog.adapters
Shape-driven adapters that convert detector frames (the DataFrames
detectors return) into the canonical :class:~ts_shape.eventlog.model.EventLog.
There is one adapter implementation per shape (point, interval, summary,
static). The per-method specifics live in
:mod:ts_shape.eventlog.taxonomy (the REGISTRY). A custom adapter for
a specific (class, method) pair can be registered with
@register_adapter(...) to override the shape-driven default — useful
for the few detectors whose frame layout does not fit any standard shape.
| Name | Description |
|---|---|
MissingCanonicalColumn | A detector frame lacks a time column of its shape. |
| Name | Description |
|---|---|
register_adapter | Register a custom adapter for a specific (class, method). |
get_override | Return the custom adapter registered for (class, method). |
has_override | Return True iff a custom adapter is registered for (class, method). |
clear_overrides | Remove registered override(s). |
adapt | Convert one detector's output into a canonical :class:EventLog. |
register_adapter
register_adapter(
class_name: str, method_name: str
) -> Callable[[AdapterFn], AdapterFn]
Register a custom adapter for a specific (class, method).
The function will be called with (detector_frame, *, rule, detector, objects, qualifiers).
get_override
get_override(class_name: str, method_name: str) -> AdapterFn | None
Return the custom adapter registered for (class, method).
Deprecated class and method names resolve to their current names.
| Name | Type | Description | Default |
|---|---|---|---|
class_name | str | Detector class name, e.g. "MachineStateEvents". | required |
method_name | str | Method name on that class. | required |
| Type | Description |
|---|---|
AdapterFn | None | The registered adapter function, or None when the shape-driven |
AdapterFn | None | default applies. |
has_override
has_override(class_name: str, method_name: str) -> bool
Return True iff a custom adapter is registered for (class, method).
clear_overrides
clear_overrides(
class_name: str | None = None, method_name: str | None = None
) -> None
Remove registered override(s).
- No arguments: clear every registration (typical test teardown).
- Both arguments: clear that specific
(class, method)only. - Class name only: clear every override on that class.
Deprecated class and method names (e.g. CycleTimeTracking) resolve
to their current names, like :func:register_adapter. Has no effect if
the targeted entries are already absent.
| Name | Type | Description | Default |
|---|---|---|---|
class_name | str | None | Detector class name; None clears every registration. | None |
method_name | str | None | Method name; None clears every method of class_name. | None |
| Type | Description |
|---|---|
ValueError | If method_name is given without class_name. |
MissingCanonicalColumn
Bases: ColumnNotFoundError, KeyError
A detector frame lacks a time column of its shape.
A :class:~ts_shape.errors.ColumnNotFoundError like every missing column,
and a KeyError for code written against earlier releases.
adapt
adapt(
frame: pd.DataFrame,
*,
rule: LabelRule,
detector: str,
objects: Mapping[str, object] | None = None,
qualifiers: Mapping[str, str] | None = None,
timestamp: object | None = None
) -> EventLog
Convert one detector's output into a canonical :class:EventLog.
| Name | Type | Description | Default |
|---|---|---|---|
frame | DataFrame | The detector frame. | required |
rule | LabelRule | The label rule of the detector method. | required |
detector | str | "ClassName.method_name", written to ts_shape:detector. | required |
objects | Mapping[str, object] | None | Object bindings (see :func:~ts_shape.eventlog.to_event_log). | None |
qualifiers | Mapping[str, str] | None | Relation qualifier per object type. | None |
timestamp | object | None | Timestamp of static shape events; default :data:STATIC_TIMESTAMP (the Unix epoch, UTC). | None |
| Type | Description |
|---|---|
EventLog | The event log; an empty one for an empty frame. |