Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,13 @@


def test_cursor_data():
from matplotlib.backend_bases import MouseEvent

fig, ax = plt.subplots()
im = ax.imshow(np.arange(100).reshape(10, 10), origin='upper')

x, y = 4, 4
xdisp, ydisp = ax.transData.transform([x, y])

event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 352 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:352 column:13} end:{line:352 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) == 44

# Now try for a point outside the image
Expand All @@ -359,7 +357,7 @@
x, y = 10.1, 4
xdisp, ydisp = ax.transData.transform([x, y])

event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 360 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:360 column:13} end:{line:360 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) is None

# Hmm, something is wrong here... I get 0, not None...
Expand All @@ -377,7 +375,7 @@
x, y = 4, 4
xdisp, ydisp = ax.transData.transform([x, y])

event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 378 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:378 column:13} end:{line:378 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) == 44

fig, ax = plt.subplots()
Expand All @@ -386,7 +384,7 @@
x, y = 0.25, 0.25
xdisp, ydisp = ax.transData.transform([x, y])

event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 387 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:387 column:13} end:{line:387 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) == 55

# Now try for a point outside the image
Expand All @@ -394,13 +392,13 @@
x, y = 0.75, 0.25
xdisp, ydisp = ax.transData.transform([x, y])

event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 395 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:395 column:13} end:{line:395 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) is None

x, y = 0.01, -0.01
xdisp, ydisp = ax.transData.transform([x, y])

event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 401 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:401 column:13} end:{line:401 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) is None

# Now try with additional transform applied to the image artist
Expand All @@ -409,7 +407,7 @@
transform=trans + ax.transData)
x, y = 3, 10
xdisp, ydisp = ax.transData.transform([x, y])
event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 410 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:410 column:13} end:{line:410 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) == 44


Expand All @@ -425,8 +423,6 @@
]
)
def test_cursor_data_nonuniform(xy, data):
from matplotlib.backend_bases import MouseEvent

# Non-linear set of x-values
x = np.array([0, 1, 4, 9, 16])
y = np.array([0, 1, 2, 3, 4])
Expand All @@ -441,7 +437,7 @@
ax.set_ylim(y.min() - 2, y.max())

xdisp, ydisp = ax.transData.transform(xy)
event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)

Check warning on line 440 in lib/matplotlib/tests/test_image.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Undefined name `MouseEvent` Raw Output: message:"Undefined name `MouseEvent`" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_image.py" range:{start:{line:440 column:13} end:{line:440 column:23}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"undefined-name" url:"https://docs.astral.sh/ruff/rules/undefined-name"}
assert im.get_cursor_data(event) == data, (im.get_cursor_data(event), data)


Expand Down
Loading