Skip to content

Commit 8e68afd

Browse files
pre-commit-ci[bot]timtreis
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 962b831 commit 8e68afd

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/spatialdata_plot/pl/render.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,9 @@ def _render_labels(
13481348
else:
13491349
assert color_source_vector is None
13501350

1351-
def _draw_labels(seg_erosionpx: int | None, seg_boundaries: bool, alpha: float,
1352-
outline_color = None) -> matplotlib.image.AxesImage:
1351+
def _draw_labels(
1352+
seg_erosionpx: int | None, seg_boundaries: bool, alpha: float, outline_color=None
1353+
) -> matplotlib.image.AxesImage:
13531354
labels = _map_color_seg(
13541355
seg=label.values,
13551356
cell_id=instance_id,
@@ -1405,7 +1406,7 @@ def _draw_labels(seg_erosionpx: int | None, seg_boundaries: bool, alpha: float,
14051406
seg_erosionpx=render_params.contour_px,
14061407
seg_boundaries=True,
14071408
alpha=render_params.outline_alpha,
1408-
outline_color=render_params.outline_color
1409+
outline_color=render_params.outline_color,
14091410
)
14101411

14111412
# pass the less-transparent _cax for the legend

src/spatialdata_plot/pl/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
import dask
1414
import datashader as ds
1515
import matplotlib
16+
import matplotlib.colors as mcolors
1617
import matplotlib.patches as mpatches
1718
import matplotlib.path as mpath
1819
import matplotlib.pyplot as plt
19-
import matplotlib.colors as mcolors
2020
import matplotlib.ticker
2121
import matplotlib.transforms as mtransforms
2222
import numpy as np
@@ -56,7 +56,6 @@
5656
from shapely.errors import GEOSException
5757
from skimage.color import label2rgb
5858
from skimage.morphology import erosion, footprint_rectangle
59-
from skimage.segmentation import find_boundaries
6059
from skimage.util import map_array
6160
from spatialdata import (
6261
SpatialData,
@@ -1213,7 +1212,7 @@ def _map_color_seg(
12131212
if seg_boundaries:
12141213
if seg.shape[0] == 1:
12151214
seg = np.squeeze(seg, axis=0)
1216-
1215+
12171216
# Binary boundary mask
12181217
boundary_mask = seg.astype(bool)
12191218

@@ -1234,11 +1233,11 @@ def _map_color_seg(
12341233
else:
12351234
# assume it's your Color object
12361235
outline_rgba = mcolors.to_rgba(outline_color.get_hex_with_alpha())
1237-
1236+
12381237
# Apply outline color to boundary pixels, but keep original alpha from val_im
1239-
seg_float[boundary_mask, :3] = outline_rgba[:3] # RGB
1238+
seg_float[boundary_mask, :3] = outline_rgba[:3] # RGB
12401239
seg_float[boundary_mask, 3] = alpha_channel[boundary_mask] * outline_rgba[3] # scale alpha
1241-
1240+
12421241
return seg_float # H x W x 4, valid RGBA
12431242

12441243
if len(val_im.shape) != len(seg_im.shape):

0 commit comments

Comments
 (0)