From bcdc3d289e80a95d216271014b9a30215e60f180 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Braun Date: Fri, 22 May 2026 01:17:46 +0200 Subject: [PATCH] Fixes #343: document cycc functions in tslearn.metrics API reference The functions cdist_normalized_cc and y_shifted_sbd_vec are re-exported via tslearn.metrics.__all__ (from tslearn/metrics/cycc.py) but were missing from the Sphinx autosummary in docs/gen_modules/tslearn.metrics.rst, so they did not show up on readthedocs. Add them to the autosummary and a guard test that fails if either symbol drifts out of the docs while staying in __all__. --- CHANGELOG.md | 3 +++ docs/gen_modules/tslearn.metrics.rst | 2 ++ tests/test_metrics.py | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01ef9767..53c2d27f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ to retrieve optimal classification timing. * `TimeSeriesScalerMinMax` and `TimeSeriesScalerMeanVariance` now scales based on fitted data characteristics when `per_timeseries` is False. ([#280](https://github.com/tslearn-team/tslearn/issues/280)) * Fix `LearningShapelets.shapelets_` attribute computation. +* Document `cdist_normalized_cc` and `y_shifted_sbd_vec` in the `tslearn.metrics` +API reference — they were already exported via `tslearn.metrics.__all__`, just +missing from the Sphinx autosummary. ([#343](https://github.com/tslearn-team/tslearn/issues/343)) ## [v0.8.1] diff --git a/docs/gen_modules/tslearn.metrics.rst b/docs/gen_modules/tslearn.metrics.rst index 4d43ea9d..5c7088be 100644 --- a/docs/gen_modules/tslearn.metrics.rst +++ b/docs/gen_modules/tslearn.metrics.rst @@ -45,3 +45,5 @@ tslearn.metrics frechet_path frechet_path_from_metric frechet_accumulated_matrix + cdist_normalized_cc + y_shifted_sbd_vec diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 184cf4db..49a8c4a7 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -1111,3 +1111,30 @@ def test_sax(): dataset2=[[-1, 0, 1], [1, 0, 1]], ) np.testing.assert_equal(dists, expected) + + +def test_cycc_functions_documented(): + """Regression test for #343: cross-correlation helpers exported from + ``tslearn.metrics`` (sourced in ``cycc.py``) must appear in the + Sphinx autosummary so they show up in the generated reference docs. + """ + import pathlib + + # Symbols re-exported from cycc.py — these are part of the public API + # via ``tslearn.metrics.__all__`` but historically were absent from the + # autosummary block, leaving them undocumented on readthedocs. + cycc_public = ["cdist_normalized_cc", "y_shifted_sbd_vec"] + for name in cycc_public: + assert name in tslearn.metrics.__all__, ( + f"{name} is expected to be re-exported from tslearn.metrics" + ) + + repo_root = pathlib.Path(__file__).resolve().parents[1] + rst_path = repo_root / "docs" / "gen_modules" / "tslearn.metrics.rst" + assert rst_path.is_file(), f"missing {rst_path}" + rst_text = rst_path.read_text() + for name in cycc_public: + assert name in rst_text, ( + f"{name} is exported by tslearn.metrics but missing from " + f"docs/gen_modules/tslearn.metrics.rst autosummary" + )