Skip to content

Commit 96ef58d

Browse files
authored
Merge branch 'main' into bugfix/416-clipping-warning-images
2 parents 2f410d8 + 70da5b9 commit 96ef58d

7 files changed

Lines changed: 18 additions & 8 deletions

File tree

.github/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ changelog:
44
- release-ignore
55
authors:
66
- pre-commit-ci
7+
- pre-commit-ci[bot]
78
categories:
89
- title: Added
910
labels:

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
pip install pytest-cov
5050
- name: Install dependencies
5151
run: |
52+
pip install numpy
5253
pip install --pre -e ".[dev,test,pre]"
5354
- name: Test
5455
env:

.mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[mypy]
22
python_version = 3.10
3-
plugins = numpy.typing.mypy_plugin
43

54
ignore_errors = False
65
warn_redundant_casts = True

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ ci:
99
skip: []
1010
repos:
1111
- repo: https://github.com/rbubley/mirrors-prettier
12-
rev: v3.5.3
12+
rev: v3.6.2
1313
hooks:
1414
- id: prettier
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.11.9
16+
rev: v0.12.11
1717
hooks:
1818
- id: ruff
1919
args: [--fix, --exit-non-zero-on-fix]
2020
- id: ruff-format
2121
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: v1.15.0
22+
rev: v1.17.1
2323
hooks:
2424
- id: mypy
2525
additional_dependencies: [numpy, types-requests]

src/spatialdata_plot/pl/basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ def show(
895895
cs_contents.query(f"cs == '{cs}'").iloc[0, :].values.tolist()
896896
)
897897
ax = fig_params.ax if fig_params.axs is None else fig_params.axs[i]
898+
assert isinstance(ax, Axes)
898899

899900
wants_images = False
900901
wants_labels = False

src/spatialdata_plot/pl/render.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def _render_shapes(
340340
vmin = aggregate_with_reduction[0].values if norm.vmin is None else norm.vmin
341341
vmax = aggregate_with_reduction[1].values if norm.vmax is None else norm.vmax
342342
if (norm.vmin is not None or norm.vmax is not None) and norm.vmin == norm.vmax:
343+
assert norm.vmin is not None
344+
assert norm.vmax is not None
343345
# value (vmin=vmax) is placed in the middle of the colorbar so that we can distinguish it from over and
344346
# under values in case clip=True or clip=False with cmap(under)=cmap(0) & cmap(over)=cmap(1)
345347
vmin = norm.vmin - 0.5
@@ -693,6 +695,8 @@ def _render_points(
693695
vmin = aggregate_with_reduction[0].values if norm.vmin is None else norm.vmin
694696
vmax = aggregate_with_reduction[1].values if norm.vmax is None else norm.vmax
695697
if (norm.vmin is not None or norm.vmax is not None) and norm.vmin == norm.vmax:
698+
assert norm.vmin is not None
699+
assert norm.vmax is not None
696700
# value (vmin=vmax) is placed in the middle of the colorbar so that we can distinguish it from over and
697701
# under values in case clip=True or clip=False with cmap(under)=cmap(0) & cmap(over)=cmap(1)
698702
vmin = norm.vmin - 0.5

src/spatialdata_plot/pl/utils.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ def _prepare_cmap_norm(
526526

527527
cmap = copy(cmap)
528528

529+
assert isinstance(cmap, Colormap), f"Invalid type of `cmap`: {type(cmap)}, expected `Colormap`."
530+
529531
if norm is None:
530532
norm = Normalize(vmin=None, vmax=None, clip=False)
531533

@@ -2076,7 +2078,7 @@ def _validate_image_render_params(
20762078
if isinstance(palette, list):
20772079
# case A: single palette for all channels
20782080
if len(palette) == 1:
2079-
palette_length = len(channel) if channel is not None else len(spatial_element_ch)
2081+
palette_length = len(channel_list) if channel_list is not None else len(spatial_element_ch)
20802082
palette = palette * palette_length
20812083
# case B: one palette per channel (either given or derived from channel length)
20822084
channels_to_use = spatial_element_ch if element_params[el]["channel"] is None else channel
@@ -2090,9 +2092,9 @@ def _validate_image_render_params(
20902092

20912093
if (cmap := param_dict["cmap"]) is not None:
20922094
if len(cmap) == 1:
2093-
cmap_length = len(channel) if channel is not None else len(spatial_element_ch)
2095+
cmap_length = len(channel_list) if channel_list is not None else len(spatial_element_ch)
20942096
cmap = cmap * cmap_length
2095-
if (channel is not None and len(cmap) != len(channel)) or len(cmap) != len(spatial_element_ch):
2097+
if (channel_list is not None and len(cmap) != len(channel_list)) or len(cmap) != len(spatial_element_ch):
20962098
cmap = None
20972099
element_params[el]["cmap"] = cmap
20982100
element_params[el]["norm"] = param_dict["norm"]
@@ -2388,7 +2390,9 @@ def _get_datashader_trans_matrix_of_single_element(
23882390
# no flipping needed
23892391
return tm
23902392
# for a Translation, we need the transposed transformation matrix
2391-
return tm.T
2393+
tm_T = tm.T
2394+
assert isinstance(tm_T, np.ndarray)
2395+
return tm_T
23922396

23932397

23942398
def _get_transformation_matrix_for_datashader(

0 commit comments

Comments
 (0)