PAA / SAX / 1d-SAX silently return NaN or garbage when n_segments is larger than the series length

Open
#852 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@MohamedO6 is already working on this.

Since Dec 4, 2026.

  • #853 by @MohamedO6 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale

Research direction

The issue names PiecewiseAggregateApproximation, SymbolicAggregateApproximation, and OneD_SymbolicAggregateApproximation, but gives no file or test paths. Start by locating those classes and their existing tests, then check how they handle n_segments values of 0, 2.5, and values larger than the series length. Done means each class raises a clear ValueError for invalid values; an open linked pull request already covers this work.

Written by the indexing model from the issue text.

Description

With X = [[1, 2, 3]] and n_segments=5 on current main, PiecewiseAggregateApproximation returns [nan, 1, nan, 2, 3] because some segments are empty. SymbolicAggregateApproximation turns the NaN segments into arbitrary symbols without any error ([2 2 2 2 2]), and OneD_SymbolicAggregateApproximation fails with Found array with 0 sample(s) ... required by LinearRegression. n_segments=0 or 2.5 is not checked either.

Proposal: raise a clear ValueError when n_segments is not a positive integer or exceeds the series length.

I have a fix with tests ready and can open a PR if that's welcome.

Dominant language
Python
Stars
3.2k
Forks
418
Avg merge
2d 14h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tslearn-team/tslearn

All issues in tslearn-team/tslearn

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.