Avoid setting corner pixels for empty layers
@@ -1545,11 +1545,15 @@ class Layer(KeymapProvider, MousemapProvider, ABC):
else:
# The stored corner_pixels attribute must contain valid indices.
+ corners = np.zeros((2, self.ndim), dtype=int)
+ # Some empty layers (e.g. Points) may have a data extent that only
+ # contains nans, in which case the integer valued corner pixels
+ # cannot be meaningfully set.
displayed_extent = self.extent.data[:, displayed_axes]
+ if not np.all(np.isnan(displayed_extent)):
data_bbox_clipped = np.clip(
data_bbox_int, displayed_extent[0], displayed_extent[1]
)
- corners = np.zeros((2, self.ndim), dtype=int)
corners[:, displayed_axes] = data_bbox_clipped
self.corner_pixels = corners
