-
Notifications
You must be signed in to change notification settings - Fork 224
Plotting fails when plotting data with np.float16 datatype #3560
Copy link
Copy link
Closed
Labels
Description
Bug description
Signal1D fails to plot the navigation axes when using large navigation dimensions (e.g., 256 × 256) with a low-bit datatype (e.g., np.float16).
The navigation pane appears blank (white) instead of showing the expected image.
Expected behaviour
The following example (with np.float64 data) works correctly:
import hyperspy.api as hs
import numpy as np
# Generate sample data
data = np.random.random((256, 256, 10))
# This works fine
s1 = hs.signals.Signal1D(data=data)
s1.plot()This successfully plots the navigation pane (showing a static noise image).
To reproduce
Changing the datatype to np.float16 causes the navigation pane to render incorrectly:
# This shows a white navigation image
s2 = hs.signals.Signal1D(data=data)
s2.change_dtype(np.float16)
s2.plot()The resulting plot shows a white navigation pane:
Python environment:
- HyperSpy version: 2.3.0
- Python version: 3.13
Additional context
Interestingly, the issue appears when the navigation size reaches the limit of what can be represented in np.float16. For example, changing the data shape to (256, 255, 10) allows s2.plot() to render correctly even with datatype changed to np.float16.
Reactions are currently unavailable