Skip to main content
Version: 0.0.98

Naming and output conventions

One concept, one name. This page is the rule set for every detector, and the checklist for reviewing a new one. Older spellings still work: they are deprecated aliases that emit a DeprecationWarning naming the replacement, and they are removed only in a future major release (see Migration & Deprecations).

Classes​

KindSuffixExamples
Emits events or KPI tables from signalsEventsDowntimeEvents, OEEEvents, ReliabilityEvents
Transforms a frame into a framerole nounDoubleFilter, TimezoneShift, PowerIntegrator
Loads dataLoader / DataAccessParquetLoader
Computes featuresrole nounNumericStatistics, CycleExtractor

Methods​

ReturnsNameExamples
Events found in the datadetect_<what>detect_change_points, detect_micro_stops
A metric or KPI tablethe nounoee, mtbf_mttr, availability_trend
A metric per window<noun>_by_window, <noun>_by_shiftenpi_by_window, downtime_by_shift
Descriptive statistics<noun>_statisticscycle_time_statistics

Event classes do not use the prefixes calculate_, compute_, get_ or process_.

Parameters​

ConceptNameNot
The input framedataframedf, data
Timestamp columntime_column (default "systime")column_name, timestamp_column, systime_col
Value columnvalue_column; per role value_column_<role> (value_column_counter, value_column_state); several: value_columnscolumn_name, value_col, value_cols, column, metric, counter_column, <role>_value_column
Signal identifier columnuuid_column (also cycle_uuid_column, metadata_uuid_column, ...)uuid_col, *_uuid_col, id_column
The one signal a detector analyzessignal_uuid, or a role name when the role matters: setpoint_uuid, run_state_uuid, counter_uuiduuid, sensor_uuid
Several signalssignal_uuidssensor_uuids, uuid_list, uuids
Run / idle state signalrun_state_uuidrun_uuid, state_uuid
Event identifier of the outputevent_uuid, default "<pack>:<name>"free-form defaults such as outlier_event
Time bucket (offset string)windowfreq, period, resample
Rolling window in rowswindow_sizean integer window
Shortest event keptmin_duration (offset string)min_hold, min_length
Longest gap a value is heldmax_gap (offset string)
Sigma multipliern_sigmaz_threshold, threshold_sigma
An absolute levelthreshold
Bounds of an allowed rangelower_limit, upper_limitlow/high, lower_bound/upper_bound, low_limit/high_limit
Specification limitslower_spec, upper_speclsl, usl
Two severity levelswarning_threshold, critical_thresholdminor_threshold, moderate_threshold
Count the state at the start of the datainclude_initialinclude_first, count_initial_active
Restrict the outputonly_<what><what>_only
Counter resetshandle_resets (default True)

Signal, column and frame arguments come first. Every optional argument after them is keyword-only.

Output columns​

Every detector returns a pandas.DataFrame in one of four shapes (ts_shape.events._output):

ShapeRequired columnsUse for
pointsystime, uuid, source_uuidsomething that happened at an instant
intervalstart, end, duration_seconds, uuid, source_uuidsomething that lasted
summarystart, end, duration_secondsa value per time window
static—a table not tied to time (statistics by reason, a fitted model)
  • Time columns are tz-aware whenever the input is. Calendar labels (date, shift, period) may be added next to start and end, never instead of them.
  • Units go in the column name: _seconds, _minutes, _hours, _kwh. Percentages end in _pct and run 0–100. Fractions end in _ratio and run 0–1. A quotient that is not a share of a whole and can exceed 1 (current / baseline variance, run time / idle time, effective / theoretical resolution) ends in _factor. A bare name such as availability does not say which.
  • Durations are float seconds in duration_seconds. Timedelta columns may be added for convenience, but not instead. Any other duration is reported in <name>_seconds; a numeric duration without a unit suffix (on_time, mean_interval) says nothing about its unit. A column in another unit (_minutes, or the legacy _s) is a convenience only and sits right after its _seconds twin.
  • KPI percentages carry their basis: a _pct computed from times or counts comes with the columns it was computed from (for example run_seconds, planned_seconds, excluded_seconds, good_parts, total_parts).
  • Summary methods return a DataFrame (one row, or one row per item) with start / end / duration_seconds for the data the summary covers. A dict or list return is legacy, available only through as_frame=False.
  • Renamed columns keep their legacy spelling as a deprecated twin until the next major release: the canonical column (same values, or the same value in seconds for a _ms column) sits right after its legacy twin, so a frame reads old, new. Window bounds are the exception: start, end, duration_seconds lead every summary, and the legacy label (window_start, window_end, time) stays where it was.
  • Counts use <thing>_count (cycle_count, part_count, failure_count), never a bare count or an n_<thing> prefix. Use sample_count for samples, not n_samples.
  • Severity: a detector's severity keeps its own labels (minor/major, low/medium/high, ...). Every result with a categorical severity also has severity_level, one of info, warn, critical, so results of different detectors can be filtered together. The level comes from one shared label table (DEFAULT_SEVERITY_LEVEL: info/ok/low/minor → info, warn/warning/medium/moderate → warn, critical/high/major/severe/alarm/error → critical) plus a detector's own overrides where its labels mean something else (ToleranceDeviationEvents: minor → warn; CUSUM: high → warn). The event log's ts_shape:severity is the same severity_level. A numeric score (outlier detection) has no level.
  • Empty results keep the full column set, so code written against a normal result also works when nothing was found.
  • Precision: numbers are returned as computed. Detectors never round; rounding belongs in reports.
  • Defaults are correct: a flag that fixes a known error (handle_resets, interval_end="next_change", time_weighted, group_by_uuid) defaults to the correct behavior; the naive behavior is opt-in.

Errors and warnings​

SituationBehavior
The time column is missing (non-empty frame)ColumnNotFoundError (a ValueError) naming the column and listing the columns
The uuid column is missing (non-empty frame)ColumnNotFoundError
A value column argument names a column the frame does not haveColumnNotFoundError naming the column
A signal uuid argument (*_uuid, *_uuids) is not in a non-empty frameDataQualityWarning listing the available uuids; the result is empty. A few detectors (alarm, batch, degradation, line balancing, ...) also raise ValueError
Too little data for a statisticempty result or NaN, never a placeholder such as 0.0 or 0 %; a mode of no data is None. Results are never inf, with one exception: MaterialBalanceEvents reports imbalance_pct (and the averages and maxima built from it) as inf for a window with zero input and non-zero output (0 when nothing flowed in or out)
A code that a mapping table does not knowkept unchanged, with a DataQualityWarning counting them
Input rows are skipped (non-numeric values, unreadable files, malformed spec entries)DataQualityWarning saying what was skipped; never silent
A deprecated name is usedDeprecationWarning naming the replacement

The uuid and column checks are applied to every detector in ts_shape.events by its base class, so they behave the same in every pack. Transforms, features, signals, the event log and the context helpers use the same checks (ts_shape.utils.frames), and contract tests run every public function on empty, tz-aware, nullable and pyarrow input. They report the call you made, not the detector's internal calls. A missing value column (value_column, value_column_<role>, ...) raises ColumnNotFoundError naming the column when the method looks it up.

Deprecation policy​

Renames go through deprecation, never straight to removal:

  1. The old spelling keeps working and warns. Every helper in ts_shape.utils.deprecation emits a DeprecationWarning that names the replacement and points at the caller's line. A renamed output column keeps its old spelling as a twin (no warning is possible for a column).
  2. Deprecated names are removed only in a major release, the next one being 1.0. A deprecation lives at least 3 months and through at least one minor release before it can be removed.
  3. Before 1.0, a release candidate switches the warnings to FutureWarning (shown by default everywhere, notebooks included) and leaves the twin columns out by default, at least 4 weeks before the release.
  4. Every deprecation gets an entry in Migration and deprecations with the old and the new spelling. The full current list is generated from the code: Deprecated names.
  5. Supported Python versions follow SPEC 0 (three years after a Python release). Dropping a Python version is not a rename: pip keeps installing the last ts-shape release that supports the older Python.

Wording​

American spelling (analyze, normalize, behavior). Use:

  • signal for a uuid's time series, not tag or series;
  • window for a time bucket;
  • downtime for unplanned stops, idle for planned ones;
  • part for a produced unit;
  • NOK for a rejected part;
  • setpoint for a controller target, target for a production goal.