Skip to content

fix: correct YRangeCursorTool annotation when cursors are inverted#307

Open
hieusats wants to merge 1 commit into
DataLab-Platform:mainfrom
hieusats:fix/yrange-cursor-annotation
Open

fix: correct YRangeCursorTool annotation when cursors are inverted#307
hieusats wants to merge 1 commit into
DataLab-Platform:mainfrom
hieusats:fix/yrange-cursor-annotation

Conversation

@hieusats
Copy link
Copy Markdown

Summary

Fixes #306

When the top Y-range cursor is dragged below the bottom cursor (ymin > ymax), the annotation label showed an invalid inequality (e.g. 5 < y < 2) and a negative delta value (∆y=-3).

Changes

In datalab/gui/docks.pyCurveStatsToolFunctions.set_labelfuncs():

  • Line 97: Use min(ymin, ymax) / max(ymin, ymax) to always display the smaller value on the left
  • Line 98: Use abs(ymax - ymin) so delta is always positive

Test Plan

  • Verified the fix logic: min()/max() ensures correct ordering, abs() ensures positive delta
  • Manual test: drag top cursor below bottom cursor, verify annotation shows valid inequality and positive delta

When the top Y-range cursor is dragged below the bottom cursor
(ymin > ymax), the annotation label showed an invalid inequality
(e.g. '5 < y < 2') and a negative delta (no physical meaning).

Fix by sorting the min/max values and using abs() for the delta.

Fixes DataLab-Platform#306
@dappham-CODRA
Copy link
Copy Markdown
Contributor

Hi 👋
Thanks for opening this pull request.
As part of our good development practices, could you please:

run ruff and the project linter,
apply the required fixes to address any warnings or errors,
make sure all CI checks pass successfully.

This PR (and the related issue) is intended to be an entry point for collaboration on the project, so ensuring the code follows our quality and style standards helps keep contributions consistent and easier to review.
Thanks in advance for the updates 👍
Feel free to ask if you need any guidance.

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.

YRangeCursorTool: annotation shows incorrect inequality and negative ∆y when y0 > y1

2 participants