Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ValueError by passing a tuple to color= instead of a numpy array #4221

Merged
merged 2 commits into from Sep 19, 2023

Conversation

joshuacwnewton
Copy link
Member

@joshuacwnewton joshuacwnewton commented Sep 18, 2023

Description

Previously, we would create a dict of [1,4] numpy arrays representing RGB colors + A (transparency) for each unique bval. Due to a recent matplotlib update, though, using a numpy array causes an unexpected ValueError. (matplotlib/matplotlib#26821)

This error is what's causing the current CI failures across recent PRs.

Since a tuple of size [4] results in the exact same functionality, we can bypass the error by storing tuple-based colors instead.

Linked issues

Fixes #4220.

Previously, we would create a dict of [1,4] numpy arrays representing RGB colors + A (transparency) for each point color.

Due to a recent matplotlib update, though, using a numpy array causes an unexpected ValueError.

Since a list of size [4] results in the exact same functionality, we can just bypass the error by storing list-based colors instead.
@joshuacwnewton joshuacwnewton added bug category: fixes an error in the code upstream Issue caused by software dependencies sct_dmri_display_bvecs context: labels Sep 18, 2023
Using a list implies that the color could be mutated at some point, but we only ever consume the color after creating the dict of colors.
@joshuacwnewton joshuacwnewton changed the title Fix ValueError by passing a list to color= instead of a numpy array Fix ValueError by passing a tuple to color= instead of a numpy array Sep 18, 2023
Copy link
Member

@mguaypaq mguaypaq left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@mguaypaq mguaypaq merged commit d77b1d1 into master Sep 19, 2023
24 checks passed
@mguaypaq mguaypaq deleted the jn/4220-fix-matplotlib-valueerror branch September 19, 2023 13:53
@joshuacwnewton joshuacwnewton added this to the 6.1 milestone Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category: fixes an error in the code sct_dmri_display_bvecs context: upstream Issue caused by software dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New test failures: The truth value of an array with more than one element is ambiguous
3 participants