base
base ¤
Base class and architecture guidelines for ts-shape.
ts-shape uses two complementary patterns for data processing. Choose the right one based on the complexity of the operation:
Stateless classmethods — use when:
- The operation is a single, self-contained transformation (filter, calculate, convert, aggregate).
- There is no shared configuration between methods.
- The result depends only on the inputs (pure function).
- Examples:
IntegerCalc,StringFilter,NumericStatistics,DateTimeFilter,LambdaProcessor.
Stateful instance classes — use when:
- Multiple related methods share configuration (column names, signal UUIDs, thresholds, tolerances).
- The constructor validates or preprocesses data once for many operations (e.g. sorting, filtering to a specific UUID).
- The domain workflow has a natural setup phase before analysis (e.g. compute control limits, then apply SPC rules).
- Examples:
DataHarmonizer,OutlierDetectionEvents,MachineStateEvents,OEEEvents, all event classes.
Pipeline — use when chaining multiple steps:
- Chains transforms (
.transform()) and detectors (.detect()) into one reusable definition; works with both class patterns above and plain callables. - Supports
$prev/$inputsentinels for multi-DataFrame wiring andrun_steps()for intermediate-result capture. - See
ts_shape.pipeline.
Base ¤
Base(dataframe: DataFrame, time_column: str = 'systime')
Keep a sorted copy of dataframe with a datetime time column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Long-format input ( |
required |
time_column
|
str
|
Timestamp column to convert and sort by. When it is
missing, datetime or text columns whose name contains "time"
or "date" are read as timestamps instead (with a
:class: |
'systime'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ColumnNotFoundError
|
For a detector ( |