Skip to content

Commit 07d07db

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 64b360d commit 07d07db

File tree

2 files changed

+91
-296
lines changed

2 files changed

+91
-296
lines changed

src/spatialdata_plot/pl/basic.py

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,7 @@ def _copy(
148148
shapes=self._sdata.shapes if shapes is None else shapes,
149149
tables=self._sdata.tables if tables is None else tables,
150150
)
151-
sdata.plotting_tree = (
152-
self._sdata.plotting_tree
153-
if hasattr(self._sdata, "plotting_tree")
154-
else OrderedDict()
155-
)
151+
sdata.plotting_tree = self._sdata.plotting_tree if hasattr(self._sdata, "plotting_tree") else OrderedDict()
156152

157153
return sdata
158154

@@ -425,9 +421,7 @@ def render_points(
425421
if not isinstance(method, str):
426422
raise TypeError("Parameter 'method' must be a string.")
427423
if method not in ["matplotlib", "datashader"]:
428-
raise ValueError(
429-
"Parameter 'method' must be either 'matplotlib' or 'datashader'."
430-
)
424+
raise ValueError("Parameter 'method' must be either 'matplotlib' or 'datashader'.")
431425

432426
sdata = self._copy()
433427
sdata = _verify_plotting_tree(sdata)
@@ -825,9 +819,7 @@ def show(
825819
render_cmds.append((cmd, params))
826820

827821
if not render_cmds:
828-
raise TypeError(
829-
"Please specify what to plot using the 'render_*' functions before calling 'imshow()'."
830-
)
822+
raise TypeError("Please specify what to plot using the 'render_*' functions before calling 'imshow()'.")
831823

832824
if title is not None:
833825
if isinstance(title, str):
@@ -844,26 +836,18 @@ def show(
844836
ax_x_min, ax_x_max = ax.get_xlim()
845837
ax_y_max, ax_y_min = ax.get_ylim() # (0, 0) is top-left
846838

847-
coordinate_systems = (
848-
sdata.coordinate_systems
849-
if coordinate_systems is None
850-
else coordinate_systems
851-
)
839+
coordinate_systems = sdata.coordinate_systems if coordinate_systems is None else coordinate_systems
852840
if isinstance(coordinate_systems, str):
853841
coordinate_systems = [coordinate_systems]
854842

855843
for cs in coordinate_systems:
856844
if cs not in sdata.coordinate_systems:
857-
raise ValueError(
858-
f"Unknown coordinate system '{cs}', valid choices are: {sdata.coordinate_systems}"
859-
)
845+
raise ValueError(f"Unknown coordinate system '{cs}', valid choices are: {sdata.coordinate_systems}")
860846

861847
# Check if user specified only certain elements to be plotted
862848
cs_contents = _get_cs_contents(sdata)
863849

864-
elements_to_be_rendered = _get_elements_to_be_rendered(
865-
render_cmds, cs_contents, cs
866-
)
850+
elements_to_be_rendered = _get_elements_to_be_rendered(render_cmds, cs_contents, cs)
867851

868852
# filter out cs without relevant elements
869853
cmds = [cmd for cmd, _ in render_cmds]
@@ -930,10 +914,8 @@ def show(
930914
# We create a copy here as the wanted elements can change from one cs to another.
931915
params_copy = deepcopy(params)
932916
if cmd == "render_images" and has_images:
933-
wanted_elements, wanted_images_on_this_cs, wants_images = (
934-
_get_wanted_render_elements(
935-
sdata, wanted_elements, params_copy, cs, "images"
936-
)
917+
wanted_elements, wanted_images_on_this_cs, wants_images = _get_wanted_render_elements(
918+
sdata, wanted_elements, params_copy, cs, "images"
937919
)
938920

939921
if wanted_images_on_this_cs:
@@ -954,10 +936,8 @@ def show(
954936
)
955937

956938
elif cmd == "render_shapes" and has_shapes:
957-
wanted_elements, wanted_shapes_on_this_cs, wants_shapes = (
958-
_get_wanted_render_elements(
959-
sdata, wanted_elements, params_copy, cs, "shapes"
960-
)
939+
wanted_elements, wanted_shapes_on_this_cs, wants_shapes = _get_wanted_render_elements(
940+
sdata, wanted_elements, params_copy, cs, "shapes"
961941
)
962942

963943
if wanted_shapes_on_this_cs:
@@ -972,10 +952,8 @@ def show(
972952
)
973953

974954
elif cmd == "render_points" and has_points:
975-
wanted_elements, wanted_points_on_this_cs, wants_points = (
976-
_get_wanted_render_elements(
977-
sdata, wanted_elements, params_copy, cs, "points"
978-
)
955+
wanted_elements, wanted_points_on_this_cs, wants_points = _get_wanted_render_elements(
956+
sdata, wanted_elements, params_copy, cs, "points"
979957
)
980958

981959
if wanted_points_on_this_cs:
@@ -990,19 +968,15 @@ def show(
990968
)
991969

992970
elif cmd == "render_labels" and has_labels:
993-
wanted_elements, wanted_labels_on_this_cs, wants_labels = (
994-
_get_wanted_render_elements(
995-
sdata, wanted_elements, params_copy, cs, "labels"
996-
)
971+
wanted_elements, wanted_labels_on_this_cs, wants_labels = _get_wanted_render_elements(
972+
sdata, wanted_elements, params_copy, cs, "labels"
997973
)
998974

999975
if wanted_labels_on_this_cs:
1000976
if (table := params_copy.table_name) is not None:
1001977
assert isinstance(params_copy.color, str)
1002978
colors = sc.get.obs_df(sdata[table], [params_copy.color])
1003-
if isinstance(
1004-
colors[params_copy.color].dtype, pd.CategoricalDtype
1005-
):
979+
if isinstance(colors[params_copy.color].dtype, pd.CategoricalDtype):
1006980
_maybe_set_colors(
1007981
source=sdata[table],
1008982
target=sdata[table],
@@ -1034,9 +1008,7 @@ def show(
10341008
try:
10351009
t = title[i]
10361010
except IndexError as e:
1037-
raise IndexError(
1038-
"The number of titles must match the number of coordinate systems."
1039-
) from e
1011+
raise IndexError("The number of titles must match the number of coordinate systems.") from e
10401012
ax.set_title(t)
10411013
ax.set_aspect("equal")
10421014

@@ -1068,8 +1040,4 @@ def show(
10681040
# https://stackoverflow.com/a/64523765
10691041
if not hasattr(sys, "ps1"):
10701042
plt.show()
1071-
return (
1072-
(fig_params.ax if fig_params.axs is None else fig_params.axs)
1073-
if return_ax
1074-
else None
1075-
) # shuts up ruff
1043+
return (fig_params.ax if fig_params.axs is None else fig_params.axs) if return_ax else None # shuts up ruff

0 commit comments

Comments
 (0)