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

test all data types on all canvas backends #117

Open
tlambert03 opened this issue Jan 23, 2025 · 1 comment
Open

test all data types on all canvas backends #117

tlambert03 opened this issue Jan 23, 2025 · 1 comment

Comments

@tlambert03
Copy link
Member

Just spent a frustrating amount of time debugging what ended up being an issue with passing an unsupported data type to the vispy image node. there was a vague warning in the logs that I overlooked:

/Users/talley/dev/self/ndv/src/ndv/views/_vispy/_array_canvas.py:485: UserWarning: Downcasting integer data to uint16.
  data = _downcast(data)

but the phenotype was that, even though I was passing in new data, the viewer stayed static. Long story short, we need to do comprehensive basic testing to ensure that all possible numpy data types work and/or are cast as needed for the canvas backend

@tlambert03
Copy link
Member Author

ok, the stupid stupid answer was that we downcast data when creating the image texture, but not when updating:

    def set_data(self, data: np.ndarray) -> None:
        if not data.ndim == self._ndim:
            warnings.warn(
                f"Got wrong number of dimensions ({data.ndim}) for vispy "
                f"visual of type {type(self._visual)}.",
                stacklevel=2,
            )
            return
        self._visual.set_data(_downcast(data))  # <------------------------- need downcast here

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

1 participant