Skip to content

Commit b244402

Browse files
committed
moved typecheck to correct function
1 parent 5cdc924 commit b244402

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/spatialdata_plot/pl/basic.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,9 @@ def render_shapes(
257257
norm=norm,
258258
scale=scale,
259259
table_name=table_name,
260+
method=method,
260261
)
261262

262-
if not isinstance(method, str):
263-
raise TypeError("Parameter 'method' must be a string.")
264-
265-
if method not in ["matplotlib", "datashader"]:
266-
raise ValueError("Parameter 'method' must be either 'matplotlib' or 'datashader'.")
267-
268263
sdata = self._copy()
269264
sdata = _verify_plotting_tree(sdata)
270265
n_steps = len(sdata.plotting_tree.keys())

src/spatialdata_plot/pl/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,9 @@ def _type_check_params(param_dict: dict[str, Any], element_type: str) -> dict[st
16251625
if param_dict.get("table_name") and not isinstance(param_dict["table_name"], str):
16261626
raise TypeError("Parameter 'table_name' must be a string .")
16271627

1628+
if param_dict.get("method") not in ["matplotlib", "datashader", None]:
1629+
raise ValueError("If specified, parameter 'method' must be either 'matplotlib' or 'datashader'.")
1630+
16281631
return param_dict
16291632

16301633

@@ -1757,6 +1760,7 @@ def _validate_shape_render_params(
17571760
norm: Normalize | None,
17581761
scale: float | int,
17591762
table_name: str | None,
1763+
method: str | None,
17601764
) -> dict[str, dict[str, Any]]:
17611765
param_dict: dict[str, Any] = {
17621766
"sdata": sdata,
@@ -1774,6 +1778,7 @@ def _validate_shape_render_params(
17741778
"norm": norm,
17751779
"scale": scale,
17761780
"table_name": table_name,
1781+
"method": method,
17771782
}
17781783
param_dict = _type_check_params(param_dict, "shapes")
17791784

@@ -1803,6 +1808,7 @@ def _validate_shape_render_params(
18031808

18041809
element_params[el]["palette"] = param_dict["palette"] if param_dict["col_for_color"] is not None else None
18051810
element_params[el]["groups"] = param_dict["groups"] if param_dict["col_for_color"] is not None else None
1811+
element_params[el]["method"] = param_dict["method"]
18061812

18071813
return element_params
18081814

0 commit comments

Comments
 (0)