Skip to content

Commit 1a9faad

Browse files
Added better error message for mismatch in cs and ax number (#185)
* Added better error message * Updated changelog * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a30bdff commit 1a9faad

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ and this project adheres to [Semantic Versioning][].
1212

1313
### Added
1414

15-
- Pushed `get_extent` functionality upstream to `spatialdata` (#162)
1615
- Multiscale image handling: user can specify a scale, else the best scale is selected automatically given the figure size and dpi (#164)
1716
- Large images are automatically rasterized to speed up performance (#164)
17+
- Added better error message for mismatch in cs and ax number (#185)
1818

1919
### Fixed
2020

src/spatialdata_plot/pl/basic.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,15 @@ def show(
642642
elements=elements_to_be_rendered,
643643
)
644644

645+
# catch error in ruff-friendly way
646+
if ax is not None: # we'll generate matching number then
647+
n_ax = 1 if isinstance(ax, Axes) else len(ax)
648+
if len(coordinate_systems) != n_ax:
649+
raise ValueError(
650+
f"Mismatch between number of matplotlib axes objects ({n_ax}) "
651+
f"and number of coordinate systems ({len(coordinate_systems)})."
652+
)
653+
645654
# set up canvas
646655
fig_params, scalebar_params = _prepare_params_plot(
647656
num_panels=len(coordinate_systems),

0 commit comments

Comments
 (0)