Skip to content

Commit 08d2137

Browse files
authored
Merge branch 'main' into feature/202306_support_multipolygons
2 parents 2d34326 + a77e2f6 commit 08d2137

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ ci:
99
skip: []
1010
repos:
1111
- repo: https://github.com/psf/black
12-
rev: 23.3.0
12+
rev: 23.7.0
1313
hooks:
1414
- id: black
1515
- repo: https://github.com/pre-commit/mirrors-prettier
16-
rev: v3.0.0-alpha.9-for-vscode
16+
rev: v3.0.1
1717
hooks:
1818
- id: prettier
1919
- repo: https://github.com/asottile/blacken-docs
20-
rev: 1.13.0
20+
rev: 1.15.0
2121
hooks:
2222
- id: blacken-docs
2323
- repo: https://github.com/pre-commit/mirrors-mypy
24-
rev: v1.3.0
24+
rev: v1.5.0
2525
hooks:
2626
- id: mypy
2727
additional_dependencies: [numpy, types-requests]
2828
exclude: tests/|docs/
29-
- repo: https://github.com/charliermarsh/ruff-pre-commit
30-
rev: v0.0.272
29+
- repo: https://github.com/astral-sh/ruff-pre-commit
30+
rev: v0.0.284
3131
hooks:
3232
- id: ruff
3333
args: [--fix, --exit-non-zero-on-fix]

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning][].
1616

1717
### Fixed
1818

19+
- Legend order is now deterministic (#143)
20+
1921
## [0.0.4] - 2023-08-11
2022

2123
### Fixed

src/spatialdata_plot/pl/render.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ def assign_fill_and_outline_to_row(
233233

234234
cax = ax.add_collection(_cax)
235235

236-
palette = ListedColormap(set(color_vector)) if render_params.palette is None else render_params.palette
236+
# Using dict.fromkeys here since set returns in arbitrary order
237+
palette = ListedColormap(dict.fromkeys(color_vector)) if render_params.palette is None else render_params.palette
237238

238239
_ = _decorate_axs(
239240
ax=ax,

src/spatialdata_plot/pl/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,7 @@ def _map_color_seg(
805805

806806
if seg_boundaries:
807807
seg_bound: ArrayLike = np.clip(seg_im - find_boundaries(seg)[:, :, None], 0, 1)
808-
seg_bound = np.dstack((seg_bound, np.where(val_im > 0, 1, 0))) # add transparency here
809-
return seg_bound
808+
return np.dstack((seg_bound, np.where(val_im > 0, 1, 0))) # add transparency here
810809

811810
return np.dstack((seg_im, np.where(val_im > 0, 1, 0)))
812811

@@ -847,11 +846,11 @@ def _get_palette(
847846

848847
if isinstance(palette, str):
849848
cmap = plt.get_cmap(palette)
850-
palette = [to_hex(x) for x in cmap(np.linspace(0, 1, len_cat), alpha=alpha)]
851849
elif isinstance(palette, ListedColormap):
852-
palette = [to_hex(x) for x in palette(np.linspace(0, 1, len_cat), alpha=alpha)]
850+
cmap = palette
853851
else:
854852
raise TypeError(f"Palette is {type(palette)} but should be string or `ListedColormap`.")
853+
palette = [to_hex(np.round(x, 5)) for x in cmap(np.linspace(0, 1, len_cat), alpha=alpha)]
855854

856855
return dict(zip(categories, palette))
857856

0 commit comments

Comments
 (0)