Describe the bug
The YRangeCursorTool annotation label displays y0 < y < y1 and ∆y = y1 - y0. Unlike XRangeSelection where x values are always ordered (x0 < x1), the Y range cursor allows the user to place cursors in any order, meaning y0 can be greater than y1. This results in a mathematically incorrect inequality (y0 < y < y1 with y0 > y1) and a negative ∆y, which has no physical meaning for a range width.
To Reproduce
- Open DataLab with a signal
- Activate the Y range cursor tool (
YRangeCursorTool) from the plot toolbar
- Drag the top horizontal cursor below the bottom cursor so that the first Y value is greater than the second
- Observe the annotation label:
y0 < y < y1 is displayed with y0 > y1, and ∆y is negative
Expected behavior
The annotation should always display values in sorted order: min(y0, y1) < y < max(y0, y1), and ∆y should always be the absolute range width (positive value), regardless of cursor placement order.
Installation information
- DataLab installation type: Python package (development)
Additional context
The issue is located in datalab/gui/docks.py, in CurveStatsToolFunctions.set_labelfuncs() (line ~95):
else: # YRangeCursorTool
labelfuncs = (
("%g < y < %g", lambda ymin, ymax: (ymin, ymax)),
("∆y=%g", lambda ymin, ymax: ymax - ymin),
)
The lambdas assume ymin < ymax, but this is not guaranteed by YRangeCursorTool. The fix should sort the values:
("%g < y < %g", lambda ymin, ymax: (min(ymin, ymax), max(ymin, ymax))),
("∆y=%g", lambda ymin, ymax: abs(ymax - ymin)),
Describe the bug
The
YRangeCursorToolannotation label displaysy0 < y < y1and∆y = y1 - y0. UnlikeXRangeSelectionwhere x values are always ordered (x0 < x1), the Y range cursor allows the user to place cursors in any order, meaningy0can be greater thany1. This results in a mathematically incorrect inequality (y0 < y < y1withy0 > y1) and a negative∆y, which has no physical meaning for a range width.To Reproduce
YRangeCursorTool) from the plot toolbary0 < y < y1is displayed withy0 > y1, and∆yis negativeExpected behavior
The annotation should always display values in sorted order:
min(y0, y1) < y < max(y0, y1), and∆yshould always be the absolute range width (positive value), regardless of cursor placement order.Installation information
Additional context
The issue is located in
datalab/gui/docks.py, inCurveStatsToolFunctions.set_labelfuncs()(line ~95):The lambdas assume ymin < ymax, but this is not guaranteed by YRangeCursorTool. The fix should sort the values: