@@ -148,11 +148,7 @@ def _copy(
148
148
shapes = self ._sdata .shapes if shapes is None else shapes ,
149
149
tables = self ._sdata .tables if tables is None else tables ,
150
150
)
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 ()
156
152
157
153
return sdata
158
154
@@ -425,9 +421,7 @@ def render_points(
425
421
if not isinstance (method , str ):
426
422
raise TypeError ("Parameter 'method' must be a string." )
427
423
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'." )
431
425
432
426
sdata = self ._copy ()
433
427
sdata = _verify_plotting_tree (sdata )
@@ -825,9 +819,7 @@ def show(
825
819
render_cmds .append ((cmd , params ))
826
820
827
821
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()'." )
831
823
832
824
if title is not None :
833
825
if isinstance (title , str ):
@@ -844,26 +836,18 @@ def show(
844
836
ax_x_min , ax_x_max = ax .get_xlim ()
845
837
ax_y_max , ax_y_min = ax .get_ylim () # (0, 0) is top-left
846
838
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
852
840
if isinstance (coordinate_systems , str ):
853
841
coordinate_systems = [coordinate_systems ]
854
842
855
843
for cs in coordinate_systems :
856
844
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 } " )
860
846
861
847
# Check if user specified only certain elements to be plotted
862
848
cs_contents = _get_cs_contents (sdata )
863
849
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 )
867
851
868
852
# filter out cs without relevant elements
869
853
cmds = [cmd for cmd , _ in render_cmds ]
@@ -930,10 +914,8 @@ def show(
930
914
# We create a copy here as the wanted elements can change from one cs to another.
931
915
params_copy = deepcopy (params )
932
916
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"
937
919
)
938
920
939
921
if wanted_images_on_this_cs :
@@ -954,10 +936,8 @@ def show(
954
936
)
955
937
956
938
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"
961
941
)
962
942
963
943
if wanted_shapes_on_this_cs :
@@ -972,10 +952,8 @@ def show(
972
952
)
973
953
974
954
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"
979
957
)
980
958
981
959
if wanted_points_on_this_cs :
@@ -990,19 +968,15 @@ def show(
990
968
)
991
969
992
970
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"
997
973
)
998
974
999
975
if wanted_labels_on_this_cs :
1000
976
if (table := params_copy .table_name ) is not None :
1001
977
assert isinstance (params_copy .color , str )
1002
978
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 ):
1006
980
_maybe_set_colors (
1007
981
source = sdata [table ],
1008
982
target = sdata [table ],
@@ -1034,9 +1008,7 @@ def show(
1034
1008
try :
1035
1009
t = title [i ]
1036
1010
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
1040
1012
ax .set_title (t )
1041
1013
ax .set_aspect ("equal" )
1042
1014
@@ -1068,8 +1040,4 @@ def show(
1068
1040
# https://stackoverflow.com/a/64523765
1069
1041
if not hasattr (sys , "ps1" ):
1070
1042
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