STRETCH
STRETCH is a causal discovery method for time series where the delay from a cause to its effect changes over time. This repository contains the reusable implementation accompanying the NeurIPS 2026 paper Causal Discovery under Time-Varying Delays (see citation below).
Five-minute example
Install the package, then fit a labelled Pandas DataFrame:
pip install stretch-tscd
import numpy as np
import pandas as pd
from stretch import STRETCH
rng = np.random.default_rng(7)
n = 120
temperature = rng.normal(size=n)
demand = np.zeros(n)
for t in range(2, n):
delay = 1 if t < n // 2 else 2
demand[t] = 0.8 * temperature[t - delay] + 0.2 * demand[t - 1]
demand += 0.1 * rng.normal(size=n)
data = pd.DataFrame(
{"outdoor temperature": temperature, "power demand": demand}
)
result = STRETCH(search="greedy", max_lag=3).fit_result(data)
print(result.adjacency)
for edge, delays in result.delay_functions.items():
print(edge, delays)
Column names are preserved in the adjacency matrix and delay-function keys.
NumPy arrays are also accepted; pass variable_names=[...] to assign labels.
STRETCH supports:
search="greedy", the scalable GLOBE-wrapped search used for STRETCH-GLOBE;search="exhaustive", the complete DAG enumeration used for the main STRETCH result;search="topic", the STRETCH-TOPIC paper variant.
Exhaustive search is intended for small variable sets and may become impractical beyond five variables.
Set allow_cycles=True only when the application permits a cyclic summary graph; the default remains a DAG.
CSV command
stretch observations.csv --search greedy --max-lag 6 --output-dir results
The command writes a labelled adjacency matrix, tidy source-time-indexed delays, exact compressed delay arrays, and run metadata.
Citation
If you use STRETCH, please cite:
Lénaïg Cornanguer, David Kaltenpoth, and Jilles Vreeken. “Causal Discovery under Time-Varying Delays.” Advances in Neural Information Processing Systems, 2026.
Machine-readable citation metadata is provided in CITATION.cff.
License
STRETCH is released under the BSD 3-Clause License.
Metadata
Release files for stretch-tscd 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stretch_tscd-0.1.1.tar.gz | 45.7 kB | With provenance | Details for stretch_tscd-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stretch_tscd-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for stretch_tscd-0.1.1-py3-none-any.whl |
Total release size: 96.0 kB
Release files / stretch_tscd-0.1.1.tar.gz
| Download URL | stretch_tscd-0.1.1.tar.gz |
|---|---|
| Size | 45.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ad2d97315d0e7b177f46567f72082ebc9e3f89716e9d68bb55d10663913a3fc
|
|
BLAKE2b-256 checksum How to use checksums |
a0fc60494f0fcd366d8f61fc378eb97fa1df5e8d574c91281e8850b915904856
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / stretch_tscd-0.1.1-py3-none-any.whl
| Download URL | stretch_tscd-0.1.1-py3-none-any.whl |
|---|---|
| Size | 50.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5c5593d5e614a39abeb6f6d362b6bc7a316a50915c11fcf0b1bfb468a383d99
|
|
BLAKE2b-256 checksum How to use checksums |
006fe59df5c4f83b8fd7c01863ac64ab9a9d8a3584b6e6a3ad4094ab54ff501d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logSecurity for stretch-tscd 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for stretch_tscd-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.