Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ZeroDivisionError when altering clims for uniform image. #42

Open
gselzer opened this issue Sep 16, 2024 · 2 comments
Open

bug: ZeroDivisionError when altering clims for uniform image. #42

gselzer opened this issue Sep 16, 2024 · 2 comments

Comments

@gselzer
Copy link
Collaborator

gselzer commented Sep 16, 2024

  • ndv version: 0.0.5.dev8...
  • Python version: 3.12.3
  • Operating System: Windows 11
  • BACKEND: vispy

Description

It would seem that SceneCanvas.elements_at (naturally) throws a ZeroDivisionError, crashing python, when the contrast range is zero. This can happen when the dataset only contains a single value (example below). As this method is called from data interrogation (during hovering), this can cause unexpected crashes.

I'm not sure whether this is a vispy bug, or whether it's something we should handle here. I lean towards the former but would appreciate others' opinions.

What I Did

Here's the code for a minimal example:

import ndv
import numpy as np

img = np.ones((256, 256)) * 128
ndv.imshow(img)

Steps to reproduce the crash:

  1. Set the contrast limits to the same value.
  2. Hover over a part of the image.
@tlambert03
Copy link
Member

tlambert03 commented Sep 16, 2024

This actually will be fixed in the next vispy release... see vispy/vispy#2621

(Maybe? Is your error on that same line?)

@gselzer
Copy link
Collaborator Author

gselzer commented Sep 16, 2024

Heh, you beat me to it! Great! 💨

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

No branches or pull requests

2 participants