Skip to content

Conversation

ethanbb
Copy link

@ethanbb ethanbb commented Jul 17, 2025

Minor fix here - there is a bug in set_component_colors where if you try to use the feature of passing an ndarray as a metric, it fails with "The truth value of an array with more than one element is ambiguous." I just changed the order of the if statement to avoid this. This feature probably is not used very often, but I was trying to take advantage of it in my subclass of CNMFVizContainer and ran into the bug.

I also checked and it looks like this should not conflict with the mega-PR #45.

@ethanbb ethanbb marked this pull request as draft July 17, 2025 19:36
@ethanbb ethanbb marked this pull request as ready for review July 17, 2025 19:50
@@ -908,7 +908,7 @@ def set_component_colors(
n_contours = len(self._image_widget.gridplot[0, 0]["contours"])

# use the random colors
if metric == "random":
if isinstance(metric, str) and metric == "random":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can still fail if it's an array since it will try both conditions and an array will both fail?

suggestion:

if isinstance(metric, str):
    if metric == "random"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? If it's an array, isintance(metric, str) will be false and it will short-circuit, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants