@@ -80,9 +80,9 @@ class OutlineParams(NamedTuple):
80
80
81
81
outline : bool
82
82
gap_size : float
83
- gap_color : str
83
+ gap_color : NDArrayA | str
84
84
bg_size : float
85
- bg_color : str
85
+ bg_color : NDArrayA | str
86
86
87
87
88
88
class ScalebarParams (NamedTuple ):
@@ -287,7 +287,11 @@ def truthy(img: bool | NDArrayA | _SeqArray | None) -> bool:
287
287
return img is True or len (img ) # type: ignore
288
288
289
289
library_id = _get_library_id (
290
- adata = adata , shape = shape , spatial_key = spatial_key , library_id = library_id , library_key = library_key
290
+ adata = adata ,
291
+ shape = shape ,
292
+ spatial_key = spatial_key ,
293
+ library_id = library_id ,
294
+ library_key = library_key ,
291
295
)
292
296
if len (library_id ) > 1 and library_key is None :
293
297
raise ValueError (
@@ -342,7 +346,12 @@ def _set_coords_crops(
342
346
if crop_coord is None :
343
347
crops = [None ] * len (spatial_params .library_id )
344
348
else :
345
- crop_coord = _get_list (crop_coord , _type = tuple , ref_len = len (spatial_params .library_id ), name = "crop_coord" )
349
+ crop_coord = _get_list (
350
+ crop_coord ,
351
+ _type = tuple ,
352
+ ref_len = len (spatial_params .library_id ),
353
+ name = "crop_coord" ,
354
+ )
346
355
crops = [CropCoords (* cr ) * sf for cr , sf in zip (crop_coord , spatial_params .scale_factor )] # type: ignore[misc]
347
356
348
357
coords = adata .obsm [spatial_key ]
@@ -382,7 +391,10 @@ def subset_by_key(
382
391
raise KeyError (f"Unable to find `{ key !r} ` in `adata.obs`." ) from None
383
392
384
393
def subset_by_coords (
385
- adata : AnnData , coords : NDArrayA , img : NDArrayA | None , crop_coords : CropCoords | None
394
+ adata : AnnData ,
395
+ coords : NDArrayA ,
396
+ img : NDArrayA | None ,
397
+ crop_coords : CropCoords | None ,
386
398
) -> tuple [AnnData , NDArrayA , NDArrayA | None ]:
387
399
if crop_coords is None :
388
400
return adata , coords , img
@@ -463,7 +475,13 @@ def _set_color_source_vec(
463
475
if groups is not None :
464
476
color_source_vector = color_source_vector .remove_categories (categories .difference (groups ))
465
477
466
- color_map = _get_palette (adata , cluster_key = value_to_plot , categories = categories , palette = palette , alpha = alpha )
478
+ color_map = _get_palette (
479
+ adata ,
480
+ cluster_key = value_to_plot ,
481
+ categories = categories ,
482
+ palette = palette ,
483
+ alpha = alpha ,
484
+ )
467
485
if color_map is None :
468
486
raise ValueError ("Unable to create color palette." )
469
487
# do not rename categories, as colors need not be unique
@@ -546,7 +564,13 @@ def _plot_edges(
546
564
if not len (g .edges ):
547
565
return None
548
566
edge_collection = draw_networkx_edges (
549
- g , coords , width = edges_width , edge_color = edges_color , arrows = False , ax = ax , ** kwargs
567
+ g ,
568
+ coords ,
569
+ width = edges_width ,
570
+ edge_color = edges_color ,
571
+ arrows = False ,
572
+ ax = ax ,
573
+ ** kwargs ,
550
574
)
551
575
edge_collection .set_rasterized (sc_settings ._vector_friendly )
552
576
ax .add_collection (edge_collection )
@@ -635,7 +659,13 @@ def _decorate_axs(
635
659
# Adding legends
636
660
if color_source_vector is not None and isinstance (color_source_vector .dtype , CategoricalDtype ):
637
661
clusters = color_source_vector .categories
638
- palette = _get_palette (adata , cluster_key = value_to_plot , categories = clusters , palette = palette , alpha = alpha )
662
+ palette = _get_palette (
663
+ adata ,
664
+ cluster_key = value_to_plot ,
665
+ categories = clusters ,
666
+ palette = palette ,
667
+ alpha = alpha ,
668
+ )
639
669
_add_categorical_legend (
640
670
ax ,
641
671
color_source_vector ,
@@ -792,7 +822,12 @@ def _prepare_params_plot(
792
822
dpi = rcParams ["figure.dpi" ] if dpi is None else dpi
793
823
if num_panels > 1 and ax is None :
794
824
fig , grid = _panel_grid (
795
- num_panels = num_panels , hspace = hspace , wspace = wspace , ncols = ncols , dpi = dpi , figsize = figsize
825
+ num_panels = num_panels ,
826
+ hspace = hspace ,
827
+ wspace = wspace ,
828
+ ncols = ncols ,
829
+ dpi = dpi ,
830
+ figsize = figsize ,
796
831
)
797
832
axs : Sequence [Axes ] | None = [plt .subplot (grid [c ]) for c in range (num_panels )]
798
833
elif num_panels > 1 and ax is not None :
@@ -925,7 +960,7 @@ def _plot_scatter(
925
960
coords [:, 0 ],
926
961
coords [:, 1 ],
927
962
s = outline_params .bg_size ,
928
- c = outline_params .bg_color ,
963
+ c = outline_params .bg_color , # type: ignore[arg-type]
929
964
rasterized = sc_settings ._vector_friendly ,
930
965
cmap = cmap_params .cmap ,
931
966
norm = norm ,
@@ -936,7 +971,7 @@ def _plot_scatter(
936
971
coords [:, 0 ],
937
972
coords [:, 1 ],
938
973
s = outline_params .gap_size ,
939
- c = outline_params .gap_color ,
974
+ c = outline_params .gap_color , # type: ignore[arg-type]
940
975
rasterized = sc_settings ._vector_friendly ,
941
976
cmap = cmap_params .cmap ,
942
977
norm = norm ,
0 commit comments