From 9139deec8728cb1f39de970e41c1b01ab80c314d Mon Sep 17 00:00:00 2001 From: Gerrit Holl Date: Wed, 7 Aug 2024 09:32:57 +0200 Subject: [PATCH] Make palettize work on numpy2 Make sure palettize works on numpy2 by explicitly upcasting the bins dtype. --- trollimage/colormap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trollimage/colormap.py b/trollimage/colormap.py index c8b38e6..a4fbede 100644 --- a/trollimage/colormap.py +++ b/trollimage/colormap.py @@ -179,11 +179,11 @@ def _palettize(arr, values): def _digitize_array(arr, values): if values[0] <= values[-1]: # monotonic increasing values - outside_range_bin = max(np.nanmax(arr), values.max()) + 1 + outside_range_bin = max(np.nanmax(arr), values.max()) + np.int64(1) right = False else: # monotonic decreasing values - outside_range_bin = min(np.nanmin(arr), values.min()) - 1 + outside_range_bin = min(np.nanmin(arr), values.min()) - np.int64(1) right = True bins = np.concatenate((values, [outside_range_bin]))