fix: preserve sub-second precision when converting click coordinates …#279
Conversation
…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>
85e79e7 to
d36505d
Compare
…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>
d36505d to
6885fcc
Compare
behackl
left a comment
There was a problem hiding this comment.
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.
behackl
left a comment
There was a problem hiding this comment.
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.
fix: preserve label add_data precision after PR #279
Replaced
event.xdata * pd.to_timedelta(1, unit=time_unit)withpd.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