You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run sq.pl.spatial_segment with a custom palette of length 32, however, I get the error described later. I believe I've narrowed down the issue to line 471 in _spatial_utils.py: color_vector = color_source_vector.map(color_map, na_action=None)
color_vector needs to be a categorical type to work with other functions, however the map method doesn't always return a categorical type. It appears that palettes with the following sizes work: [16, 17, 18, 19, 20, 32, 40, 46, 53, 56, 57, 64, 71, 79, 80, 88, 92, 94, 95, 106, 107, 117, 124, 131, 136, 138, 140, 142, 143, 158, 159, 160, 166, 169, 174, 177, 184, 194, 195, 196]
I suggest adding the following line after line 471 (or something similar to ensure .map returns a category: color_vector = color_vector.astype(pd.CategoricalDtype())
Description
I'm trying to run
sq.pl.spatial_segment
with a custom palette of length 32, however, I get the error described later. I believe I've narrowed down the issue to line 471 in_spatial_utils.py
:color_vector = color_source_vector.map(color_map, na_action=None)
color_vector
needs to be a categorical type to work with other functions, however themap
method doesn't always return a categorical type. It appears that palettes with the following sizes work:[16, 17, 18, 19, 20, 32, 40, 46, 53, 56, 57, 64, 71, 79, 80, 88, 92, 94, 95, 106, 107, 117, 124, 131, 136, 138, 140, 142, 143, 158, 159, 160, 166, 169, 174, 177, 184, 194, 195, 196]
I suggest adding the following line after line 471 (or something similar to ensure
.map
returns a category:color_vector = color_vector.astype(pd.CategoricalDtype())
Minimal reproducible example
This returns the palette sizes for which the result of
.map
is categorical. The behaviour appears to depend on the number of unique palette options.Traceback
Version
1.5.0
The text was updated successfully, but these errors were encountered: