Skip to content

Commit 110ee1f

Browse files
Added handle position checks to test_widgets.py
1 parent 2566eaa commit 110ee1f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,17 +1107,41 @@ def test_range_slider(orientation):
11071107

11081108
slider.set_val((0.2, 0.6))
11091109
assert_allclose(slider.val, (0.2, 0.6))
1110+
if orientation == "vertical":
1111+
hpositions = [h.get_ydata()[0] for h in slider._handles]
1112+
assert_allclose(hpositions, (0.2, 0.6))
1113+
else:
1114+
hpositions = [h.get_xdata()[0] for h in slider._handles]
1115+
assert_allclose(hpositions, (0.2, 0.6))
11101116
box = slider.poly.get_extents().transformed(ax.transAxes.inverted())
11111117
assert_allclose(box.get_points().flatten()[idx], [0.2, .25, 0.6, .75])
11121118

11131119
slider.set_val((0.2, 0.1))
11141120
assert_allclose(slider.val, (0.1, 0.2))
1121+
if orientation == "vertical":
1122+
hpositions = [h.get_ydata()[0] for h in slider._handles]
1123+
assert_allclose(hpositions, (0.1, 0.2))
1124+
else:
1125+
hpositions = [h.get_xdata()[0] for h in slider._handles]
1126+
assert_allclose(hpositions, (0.1, 0.2))
11151127

11161128
slider.set_val((-1, 10))
11171129
assert_allclose(slider.val, (0, 1))
1130+
if orientation == "vertical":
1131+
hpositions = [h.get_ydata()[0] for h in slider._handles]
1132+
assert_allclose(hpositions, (0, 1))
1133+
else:
1134+
hpositions = [h.get_xdata()[0] for h in slider._handles]
1135+
assert_allclose(hpositions, (0, 1))
11181136

11191137
slider.reset()
1120-
assert_allclose(slider.val, [0.1, 0.34])
1138+
assert_allclose(slider.val, (0.1, 0.34))
1139+
if orientation == "vertical":
1140+
hpositions = [h.get_ydata()[0] for h in slider._handles]
1141+
assert_allclose(hpositions, (0.1, 0.34))
1142+
else:
1143+
hpositions = [h.get_xdata()[0] for h in slider._handles]
1144+
assert_allclose(hpositions, (0.1, 0.34))
11211145

11221146

11231147
def check_polygon_selector(event_sequence, expected_result, selections_count,

0 commit comments

Comments
 (0)