Skip to content

weird floating point error in setter for cmap_values #352

@kushalkolar

Description

@kushalkolar

just got this in mesviz, that value is 2^63 * -1

File ~/repos/mesmerize-viz/mesmerize_viz/_cnmf.py:845, in CNMFVizContainer.set_component_colors(self, metric, cmap)
    840         raise ValueError("Invalid colors value")
    842 for subplot in self._image_widget.gridplot:
    843     # first initialize using a quantitative cmap
    844     # this ensures that setting cmap_values will work
--> 845     subplot["contours"].cmap = "gray"
    847     subplot["contours"].cmap_values = classifier
    848     subplot["contours"].cmap = cmap

File ~/repos/fastplotlib/fastplotlib/graphics/_base.py:142, in Graphic.__setattr__(self, key, value)
    139         attr._set(value)
    140         return
--> 142 super().__setattr__(key, value)

File ~/repos/fastplotlib/fastplotlib/graphics/line_collection.py:224, in LineCollection.cmap(self, cmap)
    222 @cmap.setter
    223 def cmap(self, cmap: str):
--> 224     colors = parse_cmap_values(
    225         n_colors=len(self), cmap_name=cmap, cmap_values=self.cmap_values
    226     )
    228     for i, g in enumerate(self.graphics):
    229         g.colors = colors[i]

File ~/repos/fastplotlib/fastplotlib/utils/functions.py:283, in parse_cmap_values(n_colors, cmap_name, cmap_values)
    280     norm_cmap_values = (normalize_min_max(cmap_values) * n_colors).astype(int)
    282 # use colormap as LUT to map the cmap_values to the colormap index
--> 283 colors = np.vstack([colormap[val] for val in norm_cmap_values])
    285 return colors

File ~/repos/fastplotlib/fastplotlib/utils/functions.py:283, in <listcomp>(.0)
    280     norm_cmap_values = (normalize_min_max(cmap_values) * n_colors).astype(int)
    282 # use colormap as LUT to map the cmap_values to the colormap index
--> 283 colors = np.vstack([colormap[val] for val in norm_cmap_values])
    285 return colors

IndexError: index -9223372036854775808 is out of bounds for axis 0 with size 256

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions