Problem
tslearn.clustering.silhouette_samples handles ragged (NaN-padded) time-series input inconsistently across metric branches:
metric="euclidean" raises a raw ValueError: Input X contains NaN.
metric="dtw" silently truncates NaNs and returns results.
metric="softdtw" silently miscalculates over the NaN padding (mean shifts from 0.1795 to 0.1518 on ragged data) with no warning.
Suggested fix
Add a documented policy: either validate that all series are full-length (and raise a clear error for ragged input in every branch), or strip NaN padding consistently before all branches (including euclidean), and add tests covering ragged/NaN-padded input for every metric.
Metadata
Severity: P1
Confidence: 75
Reviewer(s): adversarial (ce-code-review run 20260821-221628-4e205155 on PR #703)
Finding ID: tslearn/clustering/utils.py:358 ragged and NaN-padded time-series input
Problem
tslearn.clustering.silhouette_sampleshandles ragged (NaN-padded) time-series input inconsistently across metric branches:metric="euclidean"raises a rawValueError: Input X contains NaN.metric="dtw"silently truncates NaNs and returns results.metric="softdtw"silently miscalculates over the NaN padding (mean shifts from 0.1795 to 0.1518 on ragged data) with no warning.Suggested fix
Add a documented policy: either validate that all series are full-length (and raise a clear error for ragged input in every branch), or strip NaN padding consistently before all branches (including euclidean), and add tests covering ragged/NaN-padded input for every metric.
Metadata
Severity: P1
Confidence: 75
Reviewer(s): adversarial (ce-code-review run 20260821-221628-4e205155 on PR #703)
Finding ID: tslearn/clustering/utils.py:358 ragged and NaN-padded time-series input