Skip to content

Commit

Permalink
Make palettize work on numpy2
Browse files Browse the repository at this point in the history
Make sure palettize works on numpy2 by explicitly upcasting the bins
dtype.
  • Loading branch information
gerritholl committed Aug 7, 2024
1 parent dc8f56b commit 9139dee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions trollimage/colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))

Expand Down

0 comments on commit 9139dee

Please sign in to comment.