Skip to content

Commit

Permalink
Fix colormaps' corresponding negative labels for NumPy v2 type casting
Browse files Browse the repository at this point in the history
Change data type from unsigned to signed int to fix `OverflowError` when adding in negative int labels to a sequence of `uint` labels.
  • Loading branch information
yoda-vid committed Oct 24, 2024
1 parent 3d48162 commit d186bdb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion magmap/plot/colormaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ def __init__(
if dup_for_neg and np.sum(labels_unique < 0) == 0:
# for labels that are only >= 0, duplicate the pos portion
# as neg so that images with or without negs use the same colors
lbls = np.array(labels_unique[labels_unique > 0][::-1])
labels_unique = np.append(
-1 * labels_unique[labels_unique > 0][::-1], labels_unique)
-1 * lbls.astype(libmag.dtype_within_range(
min(lbls), max(lbls), signed=True)), labels_unique)
num_colors = len(labels_unique)

labels_offset = 0
Expand Down

0 comments on commit d186bdb

Please sign in to comment.