API
Canonical import
from detime import DecompositionConfig, DecompResult, MethodRegistry, decompose
The canonical package import is detime. The top-level tsdecomp import and
CLI remain compatibility aliases only through 0.1.x.
DecompositionConfig
DecompositionConfig is the validated runtime contract for Python calls and
mirrors the CLI surface.
For the generated parameter-level reference, see Config Reference. For method-level input/backend/output comparison, see Method Matrix.
method: strRequired method name such asSSA,STD,STDR,MSSA,MVMD, orMEMD.params: dict[str, Any] = {}Method-specific parameters. Examples includeperiodforSTD,windowandrankforSSA, andprimary_periodfor automatic grouping.return_components: list[str] | None = NoneReserved compatibility field. Current decomposition entrypoints return the fullDecompResult; methods may ignore this field.backend: "auto" | "native" | "python" | "gpu" = "auto"Backend preference.autouses a native kernel when one exists,pythonforces the Python implementation,nativerequires the native path, andgpuraises unless a method explicitly supports it.speed_mode: "exact" | "fast" = "exact"Runtime accuracy policy. For nativeSSA,exactfollows the deterministic SVD-backed path andfastuses the approximate iterative kernel.profile: bool = FalseWhenTrue, attach runtime metadata such asruntime_msto result metadata or profile reports.device: str | None = "cpu"Reserved execution device selector. Current retained methods are CPU workflows unless a wrapper says otherwise.n_jobs: int = 1Requested parallelism hint for methods or wrappers that support it.seed: int | None = 42Random seed used by fast or approximate backends where relevant.channel_names: list[str] | None = NoneOptional channel labels for multivariate inputs. These are copied into result metadata and saved artifacts.
Validation errors come from Pydantic. Invalid backend names, negative
n_jobs, or malformed parameter payloads fail before decomposition starts.
DecompResult
DecompResult is the normalized output object returned by decompose(...).
trend: np.ndarrayTrend component. Shape matches the input layout.season: np.ndarraySeasonal or oscillatory component. Shape matches the input layout.residual: np.ndarrayRemaining unexplained component. Shape matches the input layout.components: dict[str, np.ndarray]Method-specific extra outputs such asmodes,imfs,dispersion, orseasonal_shape.meta: dict[str, Any]Runtime and provenance metadata. Common keys includemethod,backend_requested,backend_used,speed_mode,result_layout,n_channels,channel_names, andruntime_mswhen profiling is enabled.
The core reconstruction contract is:
result.trend + result.season + result.residual
which should match the original input up to the documented method tolerance.
decompose(series, config)
decompose(series, config) is the public execution entrypoint.
- Accepted input shapes:
- 1D arrays for univariate methods.
- 2D arrays of shape
(time, channels)for multivariate or channelwise methods. - Return value:
- One
DecompResult. - Common errors:
ValueErrorfor unsupported shapes or missing required parameters.RuntimeErrorwhenbackend="native"is forced but no native kernel is available.ImportErrorfor optional-backend methods such asMVMDandMEMDwithoutde-time[multivar].
Backend resolution is method-specific:
SSA,STD,STDR,MA_BASELINE,MSSA,VMD, andGABOR_CLUSTERcan use native kernels.MVMDandMEMDare optional-backend wrappers and require themultivarextra.
MethodRegistry
MethodRegistry is the machine-readable source of truth for the installed
method catalog.
MethodRegistry.list_methods()Return registered public method names.MethodRegistry.list_catalog()Return the full catalog used by docs generation, recommendation, and MCP.MethodRegistry.get_metadata(method_name)Return one catalog entry as a dictionary.MethodRegistry.get(method_name)Return the callable decomposition implementation.MethodRegistry.register(method_name)Decorator used by method modules to register implementations.
Every catalog payload now includes:
packageversioncontract_versionmethods
Every method entry exposes at least:
familyinput_modematurityimplementationdependency_tiermultivariate_supportnative_backedmin_lengthsummaryrecommended_fortypical_failure_modesassumptionsnot_recommended_foroptional_dependenciesreferencespackage_linksparameter_docsoutput_componentsexample_config
Serialization and machine-facing APIs
DeTime publishes three result views for bounded-context workflows:
fullFull arrays plus metadata and diagnostics.summaryArray shapes and summary statistics plus metadata and diagnostics.metaMetadata and diagnostics only.
Machine-facing entrypoints:
detime schema --name config|result|meta|method-registrydetime recommend --length ... --channels ...python -m detime.mcp.server
The method-registry schema and payload are versioned within the current
machine-contract series 0.1. Consumers should prefer contract_version over
guessing schema compatibility from the package version alone.
CLI summary
Supported top-level commands:
detime rundetime batchdetime profiledetime versiondetime schemadetime recommend
CLI profile reports support both json and text output, and detime profile
--format text now affects stdout as well as --output files.