Contributions
We welcome contributions to tsseg! Whether it’s adding a new algorithm, improving documentation, or fixing bugs, your help is appreciated.
Development Setup
Fork and Clone: Fork the repository on GitHub and clone it locally.
git clone https://github.com/fchavelli/tsseg.git cd tsseg
Install Development Dependencies: We use
rufffor linting/formatting andpytestfor testing.make install conda activate tsseg-env
Code Style
This project adheres to strict code quality standards to maintain professional reliability.
Linting: use
ruff check tssegto catch errors.Formatting: use
ruff format tssegto auto-format code (Black-compatible).
You can also run make lint which combines both. Please ensure all checks
pass before submitting a Pull Request.
Testing
Run the test suite using pytest:
pytest tests/
When adding a new feature, please include relevant tests in tests/.
If adding a new algorithm, ensure it passes the common estimator checks (see Detectors overview).
Algorithm test suite
The tests/algorithms/ directory contains a scikit-learn-style test suite
that automatically discovers every algorithm listed in
tsseg.algorithms.__all__. Adding a new detector to __all__ is
sufficient for it to be exercised by all generic checks — no manual test
registration required.
The suite is organised into four modules:
test_common.py— Estimator contract (scikit-learn style)Verifies the generic API contract that every
BaseSegmentermust honour:get_params/set_paramsround-tripcloneproduces an equivalent, independent estimatorfitreturnsselfis_fittedlifecycle (False→True)NotFittedErrorwhen predicting before fittingresetclears fitted statereprdoes not crashPickle round-trip (unless
cant_pickle=True)
test_tags.py— Tag contractEnsures every algorithm declares valid metadata:
returns_dense(bool),detector_type(known value)At least one
capability:*tag isTruereturns_denseis consistent withdetector_type
test_predict.py— Prediction output contractValidates that
fit_predictoutput conforms to declared tags:Sparse detectors: 1-D sorted array of indices in
[0, N)State detectors: array of integer labels of length
Nfit_predict(X)equalsfit(X); predict(X)for deterministic algorithmsRepeated calls produce identical results (determinism check)
Both univariate and multivariate inputs are exercised
test_input_validation.py— RobustnessChecks that detectors raise clear errors on bad inputs:
Invalid types (lists, strings), empty arrays
Multivariate data when
capability:multivariateisFalseNaN values when
capability:missing_valuesisFalsepd.Seriesandpd.DataFrameare accepted
Running a single algorithm:
pytest tests/algorithms/ -k PeltDetector -v
Running only the fast contract checks (no fit/predict):
pytest tests/algorithms/test_common.py tests/algorithms/test_tags.py -v
If your algorithm requires non-default constructor arguments or optional
dependencies, add an entry to ALGORITHM_OVERRIDES in
tests/algorithms/conftest.py.