Skip to content

fix: avoid reading signal values in time_diff - #665

Merged
gviejo merged 1 commit into
pynapple-org:devfrom
viranovskaya:perf/time-diff-timestamps-only
Oct 12, 2026
Merged

gviejo merged 1 commit into
pynapple-org:devfrom
viranovskaya:perf/time-diff-timestamps-only

Conversation

@viranovskaya

Copy link
Copy Markdown

Why

time_diff() only needs timestamps, but selecting each epoch with .get() also reads signal values. This causes unnecessary I/O for disk-backed time series.

This is the separate I/O follow-up requested in #640, without changes to the correlogram API.

What changed

Use the existing get_slice() interval selection to slice self.index.values directly. The signature, epoch boundaries, alignment options, output timestamps, values, and time support are unchanged. The docstring now states that signal values are not loaded.

Add 18 HDF5 regression cases covering Tsd, TsdFrame, and TsdTensor, all three alignments, and default or explicitly supplied disjoint epochs. The tests reject both dataset indexing and array materialization, and check the resulting values, timestamps, and time support.

Validation notes

The HDF5 regressions pass with the change and fail on the upstream implementation because it indexes the signal dataset.

The local full doctest run on Python 3.12, NumPy 2.5.3, and SciPy 1.18.1 still encounters the existing full-precision representation mismatch in apply_hilbert_transform. The same mismatch was reproduced on the base implementation; its documentation fix is not included here.

@viranovskaya
viranovskaya marked this pull request as ready for review October 2, 2026 12:58
@viranovskaya
viranovskaya requested a review from gviejo as a code owner October 2, 2026 12:58
@gviejo

gviejo commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

It's good thanks merging it.

@gviejo
gviejo merged commit 6e5c993 into pynapple-org:dev Oct 12, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants