Skip to main content

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stretch-tscd 0.1.0
File Size Uploaded Provenance Actions
stretch_tscd-0.1.0.tar.gz 45.7 kB With provenance Details for stretch_tscd-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stretch-tscd 0.1.0
File Interpreter ABI Platform Actions
stretch_tscd-0.1.0-py3-none-any.whl Python 3 none any Details for stretch_tscd-0.1.0-py3-none-any.whl

Total release size: 96.0 kB

Release files / stretch_tscd-0.1.0.tar.gz

Download URL stretch_tscd-0.1.0.tar.gz
Size 45.7 kB
Tags Source
SHA-256 checksum
How to use checksums
716df3af9de545ad041ddf2a608d4cf517e2d7724974ec55e9ff5cd2ed67becb
BLAKE2b-256 checksum
How to use checksums
c167bea0fdb47d7e6b17d7b66ce076dbd6047f216d80d07d9b1ca69d8e868368
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 log

Release files / stretch_tscd-0.1.0-py3-none-any.whl

Download URL stretch_tscd-0.1.0-py3-none-any.whl
Size 50.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a74834d342a8df42bef014d434fea1a3fa8c098c695c2a7422dfa0430198f47d
BLAKE2b-256 checksum
How to use checksums
c3d822f759e5457b2a0dc521c61b20c646ab297725e9e39e1430eb98dfb9e5bd
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 log

Security for stretch-tscd 0.1.0

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.

Select from 2 files

Attestation for stretch_tscd-0.1.0.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 log

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page