Skip to content

fix: preserve sub-second precision when converting click coordinates …#279

Merged
behackl merged 3 commits into
UniGrazMath:mainfrom
sorlob:feat/278-fix-label-x-value-precision
Apr 11, 2026
Merged

fix: preserve sub-second precision when converting click coordinates …#279
behackl merged 3 commits into
UniGrazMath:mainfrom
sorlob:feat/278-fix-label-x-value-precision

Conversation

@sorlob
Copy link
Copy Markdown
Collaborator

@sorlob sorlob commented Apr 10, 2026

Replaced event.xdata * pd.to_timedelta(1, unit=time_unit) with pd.to_timedelta(event.xdata, unit=time_unit) in all mouse click handlers. The old pattern truncated fractional seconds due to integer coercion; the new form preserves full sub-second resolution.

#278

…to Timedelta UniGrazMath#278

Replaced `event.xdata * pd.to_timedelta(1, unit=time_unit)` with
`pd.to_timedelta(event.xdata, unit=time_unit)` in all mouse click handlers.
The old pattern truncated fractional seconds due to integer coercion; the new
form preserves full sub-second resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sorlob sorlob requested a review from behackl April 10, 2026 19:54
@sorlob sorlob force-pushed the feat/278-fix-label-x-value-precision branch from 85e79e7 to d36505d Compare April 10, 2026 21:12
…precision UniGrazMath#278

When time_unit='s', the label's time_index has timedelta64[s] resolution.
Inserting a Timedelta with ns precision via searchsorted([time_data]) caused
a dtype cast failure because pandas could not cast the ns value into 's'.

Instead of rounding time_data down to the index resolution (which loses
sub-second precision), upcast the index to match time_data's resolution
before the searchsorted and insert calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sorlob sorlob force-pushed the feat/278-fix-label-x-value-precision branch from d36505d to 6885fcc Compare April 10, 2026 21:20
Copy link
Copy Markdown
Contributor

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me now. i pushed a small reviewer commit to keep clean: we always upcast the label index to before /, which fixes the fractional-second case without risking a silent downcast of existing higher-resolution timestamps. also added two focused tests for the original 1.5s bug and for preserving existing ns-precision entries.

Copy link
Copy Markdown
Contributor

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me now. i pushed a small reviewer commit to keep Label.add_data() clean: we always upcast the label index to ns before searchsorted/insert, which fixes the fractional-second case without risking a silent downcast of existing higher-resolution timestamps. also added two focused tests for the original 1.5s bug and for preserving existing ns-precision entries.

@behackl behackl merged commit 88ec774 into UniGrazMath:main Apr 11, 2026
10 checks passed
behackl added a commit that referenced this pull request Apr 12, 2026
fix: preserve label add_data precision after PR #279
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