Skip to content

Commit 3f38852

Browse files
authored
Merge branch 'main' into bugfix/issue467-no-warning-when-the-manually-specified-table-doesnt-actually-annotate-the-labels-element
2 parents 701be00 + c60c29d commit 3f38852

8 files changed

Lines changed: 42 additions & 39 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ repos:
1313
hooks:
1414
- id: prettier
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.12.12
16+
rev: v0.13.1
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.17.1
22+
rev: v1.18.2
2323
hooks:
2424
- id: mypy
2525
additional_dependencies: [numpy, types-requests]

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
info = metadata("spatialdata-plot")
2222
project_name = info["Name"]
2323
author = info["Author"]
24-
copyright = f"{datetime.now():%Y}, {author}."
24+
copyright = f"{datetime.now():%Y}, {author}"
2525
version = info["Version"]
2626

2727
# repository_url = f"https://github.com/scverse/{project_name}"

src/spatialdata_plot/pl/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,9 @@ def _set_color_source_vec(
780780

781781
color_source_vector = pd.Categorical(color_source_vector) # convert, e.g., `pd.Series`
782782

783+
# TODO check why table_name is not passed here.
783784
color_mapping = _get_categorical_color_mapping(
784-
adata=sdata.table,
785+
adata=sdata["table"],
785786
cluster_key=value_to_plot,
786787
color_source_vector=color_source_vector,
787788
cmap_params=cmap_params,

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_sdata_multiple_images_diverging_dims():
160160
def sdata_blobs_shapes_annotated() -> SpatialData:
161161
"""Get blobs sdata with continuous annotation of polygons."""
162162
blob = blobs()
163-
blob["table"].obs["region"] = "blobs_polygons"
163+
blob["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * blob["table"].n_obs)
164164
blob["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
165165
blob.shapes["blobs_polygons"]["value"] = [1, 2, 3, 4, 5]
166166
return blob

tests/pl/test_render_labels.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def test_plot_can_render_labels(self, sdata_blobs: SpatialData):
3131
sdata_blobs.pl.render_labels(element="blobs_labels").pl.show()
3232

3333
def test_plot_can_render_multiscale_labels(self, sdata_blobs: SpatialData):
34-
sdata_blobs["table"].obs["region"] = "blobs_multiscale_labels"
34+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_multiscale_labels"] * sdata_blobs["table"].n_obs)
3535
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_multiscale_labels"
3636
sdata_blobs.pl.render_labels("blobs_multiscale_labels").pl.show()
3737

3838
def test_plot_can_render_given_scale_of_multiscale_labels(self, sdata_blobs: SpatialData):
39-
sdata_blobs["table"].obs["region"] = "blobs_multiscale_labels"
39+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_multiscale_labels"] * sdata_blobs["table"].n_obs)
4040
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_multiscale_labels"
4141
sdata_blobs.pl.render_labels("blobs_multiscale_labels", scale="scale1").pl.show()
4242

@@ -48,7 +48,7 @@ def test_plot_can_do_rasterization(self, sdata_blobs: SpatialData):
4848
img.attrs["transform"] = sdata_blobs["blobs_labels"].transform
4949
sdata_blobs["blobs_giant_labels"] = img
5050

51-
sdata_blobs["table"].obs["region"] = "blobs_giant_labels"
51+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_giant_labels"] * sdata_blobs["table"].n_obs)
5252
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_giant_labels"
5353

5454
sdata_blobs.pl.render_labels("blobs_giant_labels").pl.show()
@@ -61,7 +61,7 @@ def test_plot_can_stop_rasterization_with_scale_full(self, sdata_blobs: SpatialD
6161
img.attrs["transform"] = sdata_blobs["blobs_labels"].transform
6262
sdata_blobs["blobs_giant_labels"] = img
6363

64-
sdata_blobs["table"].obs["region"] = "blobs_giant_labels"
64+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_giant_labels"] * sdata_blobs["table"].n_obs)
6565
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_giant_labels"
6666

6767
sdata_blobs.pl.render_labels("blobs_giant_labels", scale="full").pl.show()
@@ -108,7 +108,7 @@ def _make_tablemodel_with_categorical_labels(sdata_blobs, label):
108108
max_col = max_col.str.replace("channel_", "ch").str.replace("_sum", "")
109109
max_col = pd.Categorical(max_col, categories=set(max_col), ordered=True)
110110
adata.obs["which_max"] = max_col
111-
adata.obs["region"] = label
111+
adata.obs["region"] = pd.Categorical([label] * adata.n_obs)
112112
del adata.uns["spatialdata_attrs"]
113113
table = TableModel.parse(
114114
adata=adata,
@@ -140,7 +140,7 @@ def test_plot_two_calls_with_coloring_result_in_two_colorbars(self, sdata_blobs:
140140
sdata_blobs_local = deepcopy(sdata_blobs)
141141

142142
table = sdata_blobs_local["table"].copy()
143-
table.obs["region"] = "blobs_multiscale_labels"
143+
table.obs["region"] = pd.Categorical(["blobs_multiscale_labels"] * table.n_obs)
144144
table.uns["spatialdata_attrs"]["region"] = "blobs_multiscale_labels"
145145
table = table[:, ~table.var_names.isin(["channel_0_sum"])]
146146
sdata_blobs_local["multi_table"] = table
@@ -185,7 +185,7 @@ def test_plot_label_colorbar_uses_alpha_of_less_transparent_outline(
185185

186186
def test_can_plot_with_one_element_color_table(self, sdata_blobs: SpatialData):
187187
table = sdata_blobs["table"].copy()
188-
table.obs["region"] = "blobs_multiscale_labels"
188+
table.obs["region"] = pd.Categorical(["blobs_multiscale_labels"] * table.n_obs)
189189
table.uns["spatialdata_attrs"]["region"] = "blobs_multiscale_labels"
190190
table = table[:, ~table.var_names.isin(["channel_0_sum"])]
191191
sdata_blobs["multi_table"] = table
@@ -194,9 +194,9 @@ def test_can_plot_with_one_element_color_table(self, sdata_blobs: SpatialData):
194194
).pl.show()
195195

196196
def test_plot_subset_categorical_label_maintains_order(self, sdata_blobs: SpatialData):
197-
max_col = sdata_blobs.table.to_df().idxmax(axis=1)
198-
max_col = pd.Categorical(max_col, categories=sdata_blobs.table.to_df().columns, ordered=True)
199-
sdata_blobs.table.obs["which_max"] = max_col
197+
max_col = sdata_blobs["table"].to_df().idxmax(axis=1)
198+
max_col = pd.Categorical(max_col, categories=sdata_blobs["table"].to_df().columns, ordered=True)
199+
sdata_blobs["table"].obs["which_max"] = max_col
200200

201201
_, axs = plt.subplots(nrows=1, ncols=2, layout="tight")
202202

@@ -208,9 +208,9 @@ def test_plot_subset_categorical_label_maintains_order(self, sdata_blobs: Spatia
208208
).pl.show(ax=axs[1])
209209

210210
def test_plot_subset_categorical_label_maintains_order_when_palette_overwrite(self, sdata_blobs: SpatialData):
211-
max_col = sdata_blobs.table.to_df().idxmax(axis=1)
212-
max_col = pd.Categorical(max_col, categories=sdata_blobs.table.to_df().columns, ordered=True)
213-
sdata_blobs.table.obs["which_max"] = max_col
211+
max_col = sdata_blobs["table"].to_df().idxmax(axis=1)
212+
max_col = pd.Categorical(max_col, categories=sdata_blobs["table"].to_df().columns, ordered=True)
213+
sdata_blobs["table"].obs["which_max"] = max_col
214214

215215
_, axs = plt.subplots(nrows=1, ncols=2, layout="tight")
216216

tests/pl/test_render_points.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_plot_can_render_points(self, sdata_blobs: SpatialData):
4343
def test_plot_can_filter_with_groups_default_palette(self, sdata_blobs: SpatialData):
4444
_, axs = plt.subplots(nrows=1, ncols=2, layout="tight")
4545

46-
sdata_blobs["table"].obs["region"] = ["blobs_points"] * sdata_blobs["table"].n_obs
46+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_points"] * sdata_blobs["table"].n_obs)
4747
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_points"
4848

4949
sdata_blobs.pl.render_points(color="genes", size=10).pl.show(ax=axs[0], legend_fontsize=6)
@@ -52,7 +52,7 @@ def test_plot_can_filter_with_groups_default_palette(self, sdata_blobs: SpatialD
5252
def test_plot_can_filter_with_groups_custom_palette(self, sdata_blobs: SpatialData):
5353
_, axs = plt.subplots(nrows=1, ncols=2, layout="tight")
5454

55-
sdata_blobs["table"].obs["region"] = ["blobs_points"] * sdata_blobs["table"].n_obs
55+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_points"] * sdata_blobs["table"].n_obs)
5656
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_points"
5757

5858
sdata_blobs.pl.render_points(color="genes", size=10).pl.show(ax=axs[0], legend_fontsize=6)
@@ -61,7 +61,7 @@ def test_plot_can_filter_with_groups_custom_palette(self, sdata_blobs: SpatialDa
6161
)
6262

6363
def test_plot_coloring_with_palette(self, sdata_blobs: SpatialData):
64-
sdata_blobs["table"].obs["region"] = ["blobs_points"] * sdata_blobs["table"].n_obs
64+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_points"] * sdata_blobs["table"].n_obs)
6565
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_points"
6666
sdata_blobs.pl.render_points(
6767
color="genes",
@@ -70,12 +70,12 @@ def test_plot_coloring_with_palette(self, sdata_blobs: SpatialData):
7070
).pl.show()
7171

7272
def test_plot_coloring_with_cmap(self, sdata_blobs: SpatialData):
73-
sdata_blobs["table"].obs["region"] = ["blobs_points"] * sdata_blobs["table"].n_obs
73+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_points"] * sdata_blobs["table"].n_obs)
7474
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_points"
7575
sdata_blobs.pl.render_points(color="genes", cmap="rainbow").pl.show()
7676

7777
def test_plot_can_stack_render_points(self, sdata_blobs: SpatialData):
78-
sdata_blobs["table"].obs["region"] = ["blobs_points"] * sdata_blobs["table"].n_obs
78+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_points"] * sdata_blobs["table"].n_obs)
7979
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_points"
8080
(
8181
sdata_blobs.pl.render_points(element="blobs_points", na_color="red", size=30)

tests/pl/test_render_shapes.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _make_multi():
100100

101101
def test_plot_can_color_from_geodataframe(self, sdata_blobs: SpatialData):
102102
blob = deepcopy(sdata_blobs)
103-
blob["table"].obs["region"] = "blobs_polygons"
103+
blob["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * blob["table"].n_obs)
104104
blob["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
105105
blob.shapes["blobs_polygons"]["value"] = [1, 10, 1, 20, 1]
106106
blob.pl.render_shapes(
@@ -114,7 +114,7 @@ def test_plot_can_scale_shapes(self, sdata_blobs: SpatialData):
114114
def test_plot_can_filter_with_groups(self, sdata_blobs: SpatialData):
115115
_, axs = plt.subplots(nrows=1, ncols=2, layout="tight")
116116

117-
sdata_blobs["table"].obs["region"] = "blobs_polygons"
117+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
118118
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
119119
sdata_blobs.shapes["blobs_polygons"]["cluster"] = "c1"
120120
sdata_blobs.shapes["blobs_polygons"].iloc[3:5, 1] = "c2"
@@ -128,7 +128,7 @@ def test_plot_can_filter_with_groups(self, sdata_blobs: SpatialData):
128128
)
129129

130130
def test_plot_coloring_with_palette(self, sdata_blobs: SpatialData):
131-
sdata_blobs["table"].obs["region"] = "blobs_polygons"
131+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
132132
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
133133
sdata_blobs.shapes["blobs_polygons"]["cluster"] = "c1"
134134
sdata_blobs.shapes["blobs_polygons"].iloc[3:5, 1] = "c2"
@@ -141,21 +141,21 @@ def test_plot_coloring_with_palette(self, sdata_blobs: SpatialData):
141141
).pl.show()
142142

143143
def test_plot_colorbar_respects_input_limits(self, sdata_blobs: SpatialData):
144-
sdata_blobs["table"].obs["region"] = "blobs_polygons"
144+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
145145
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
146146
sdata_blobs.shapes["blobs_polygons"]["cluster"] = [1, 2, 3, 5, 20]
147147
sdata_blobs.pl.render_shapes("blobs_polygons", color="cluster").pl.show()
148148

149149
def test_plot_colorbar_can_be_normalised(self, sdata_blobs: SpatialData):
150-
sdata_blobs["table"].obs["region"] = "blobs_polygons"
150+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
151151
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
152152
sdata_blobs.shapes["blobs_polygons"]["cluster"] = [1, 2, 3, 5, 20]
153153
norm = Normalize(vmin=0, vmax=5, clip=True)
154154
sdata_blobs.pl.render_shapes("blobs_polygons", color="cluster", groups=["c1"], norm=norm).pl.show()
155155

156156
def test_plot_can_plot_shapes_after_spatial_query(self, sdata_blobs: SpatialData):
157157
# subset to only shapes, should be unnecessary after rasterizeation of multiscale images is included
158-
blob = SpatialData.from_elements_dict(
158+
blob = SpatialData.init_from_elements(
159159
{
160160
"blobs_circles": sdata_blobs.shapes["blobs_circles"],
161161
"blobs_multipolygons": sdata_blobs.shapes["blobs_multipolygons"],
@@ -168,7 +168,7 @@ def test_plot_can_plot_shapes_after_spatial_query(self, sdata_blobs: SpatialData
168168
cropped_blob.pl.render_shapes().pl.show()
169169

170170
def test_plot_can_plot_with_annotation_despite_random_shuffling(self, sdata_blobs: SpatialData):
171-
sdata_blobs["table"].obs["region"] = "blobs_circles"
171+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_circles"] * sdata_blobs["table"].n_obs)
172172
new_table = sdata_blobs["table"][:5]
173173
new_table.uns["spatialdata_attrs"]["region"] = "blobs_circles"
174174
new_table.obs["instance_id"] = np.array(range(5))
@@ -187,7 +187,7 @@ def test_plot_can_plot_with_annotation_despite_random_shuffling(self, sdata_blob
187187
sdata_blobs.pl.render_shapes("blobs_circles", color="annotation").pl.show()
188188

189189
def test_plot_can_plot_queried_with_annotation_despite_random_shuffling(self, sdata_blobs: SpatialData):
190-
sdata_blobs["table"].obs["region"] = "blobs_circles"
190+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_circles"] * sdata_blobs["table"].n_obs)
191191
new_table = sdata_blobs["table"][:5].copy()
192192
new_table.uns["spatialdata_attrs"]["region"] = "blobs_circles"
193193
new_table.obs["instance_id"] = np.array(range(5))
@@ -215,11 +215,12 @@ def test_plot_can_plot_queried_with_annotation_despite_random_shuffling(self, sd
215215
sdata_cropped.pl.render_shapes("blobs_circles", color="annotation").pl.show()
216216

217217
def test_plot_can_color_two_shapes_elements_by_annotation(self, sdata_blobs: SpatialData):
218-
sdata_blobs["table"].obs["region"] = "blobs_circles"
218+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_circles"] * sdata_blobs["table"].n_obs)
219219
new_table = sdata_blobs["table"][:10].copy()
220220
new_table.uns["spatialdata_attrs"]["region"] = ["blobs_circles", "blobs_polygons"]
221221
new_table.obs["instance_id"] = np.concatenate((np.array(range(5)), np.array(range(5))))
222222

223+
new_table.obs["region"] = new_table.obs["region"].cat.add_categories(["blobs_polygons"])
223224
new_table.obs.loc[5 * [False] + 5 * [True], "region"] = "blobs_polygons"
224225
new_table.obs["annotation"] = ["a", "b", "c", "d", "e", "v", "w", "x", "y", "z"]
225226
new_table.obs["annotation"] = new_table.obs["annotation"].astype("category")
@@ -231,11 +232,12 @@ def test_plot_can_color_two_shapes_elements_by_annotation(self, sdata_blobs: Spa
231232
).pl.show()
232233

233234
def test_plot_can_color_two_queried_shapes_elements_by_annotation(self, sdata_blobs: SpatialData):
234-
sdata_blobs["table"].obs["region"] = "blobs_circles"
235+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_circles"] * sdata_blobs["table"].n_obs)
235236
new_table = sdata_blobs["table"][:10].copy()
236237
new_table.uns["spatialdata_attrs"]["region"] = ["blobs_circles", "blobs_polygons"]
237238
new_table.obs["instance_id"] = np.concatenate((np.array(range(5)), np.array(range(5))))
238239

240+
new_table.obs["region"] = new_table.obs["region"].cat.add_categories(["blobs_polygons"])
239241
new_table.obs.loc[5 * [False] + 5 * [True], "region"] = "blobs_polygons"
240242
new_table.obs["annotation"] = ["a", "b", "c", "d", "e", "v", "w", "x", "y", "z"]
241243
new_table.obs["annotation"] = new_table.obs["annotation"].astype("category")
@@ -360,7 +362,7 @@ def test_plot_can_color_by_category_with_cmap(self, sdata_blobs: SpatialData):
360362
sdata_blobs.pl.render_shapes(element="blobs_polygons", color="category", cmap="cool").pl.show()
361363

362364
def test_plot_datashader_can_color_by_value(self, sdata_blobs: SpatialData):
363-
sdata_blobs["table"].obs["region"] = "blobs_polygons"
365+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
364366
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
365367
sdata_blobs.shapes["blobs_polygons"]["value"] = [1, 10, 1, 20, 1]
366368
sdata_blobs.pl.render_shapes(element="blobs_polygons", color="value", method="datashader").pl.show()
@@ -370,13 +372,13 @@ def test_plot_datashader_can_color_by_identical_value(self, sdata_blobs: Spatial
370372
We test this, because datashader internally scales the values, so when all shapes have the same value,
371373
the scaling would lead to all of them being assigned an alpha of 0, so we wouldn't see anything
372374
"""
373-
sdata_blobs["table"].obs["region"] = ["blobs_polygons"] * sdata_blobs["table"].n_obs
375+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
374376
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
375377
sdata_blobs.shapes["blobs_polygons"]["value"] = [1, 1, 1, 1, 1]
376378
sdata_blobs.pl.render_shapes(element="blobs_polygons", color="value", method="datashader").pl.show()
377379

378380
def test_plot_datashader_shades_with_linear_cmap(self, sdata_blobs: SpatialData):
379-
sdata_blobs["table"].obs["region"] = ["blobs_polygons"] * sdata_blobs["table"].n_obs
381+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
380382
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
381383
sdata_blobs.shapes["blobs_polygons"]["value"] = [1, 2, 1, 20, 1]
382384
sdata_blobs.pl.render_shapes(element="blobs_polygons", color="value", method="datashader").pl.show()
@@ -410,7 +412,7 @@ def test_plot_datashader_can_render_with_rgba_colored_outline(self, sdata_blobs:
410412
def test_plot_can_set_clims_clip(self, sdata_blobs: SpatialData):
411413
table_shapes = sdata_blobs["table"][:5].copy()
412414
table_shapes.obs.instance_id = list(range(5))
413-
table_shapes.obs["region"] = "blobs_circles"
415+
table_shapes.obs["region"] = pd.Categorical(["blobs_circles"] * table_shapes.n_obs)
414416
table_shapes.obs["dummy_gene_expression"] = [i * 10 for i in range(5)]
415417
table_shapes.uns["spatialdata_attrs"]["region"] = "blobs_circles"
416418
sdata_blobs["new_table"] = table_shapes
@@ -489,7 +491,7 @@ def test_plot_datashader_can_transform_circles(self, sdata_blobs: SpatialData):
489491
def test_plot_can_do_non_matching_table(self, sdata_blobs: SpatialData):
490492
table_shapes = sdata_blobs["table"][:3].copy()
491493
table_shapes.obs.instance_id = list(range(3))
492-
table_shapes.obs["region"] = "blobs_circles"
494+
table_shapes.obs["region"] = pd.Categorical(["blobs_circles"] * table_shapes.n_obs)
493495
table_shapes.uns["spatialdata_attrs"]["region"] = "blobs_circles"
494496
sdata_blobs["new_table"] = table_shapes
495497

tests/pl/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_plot_set_outline_accepts_str_or_float_or_list_thereof(self, sdata_blobs
4444
def test_plot_colnames_that_are_valid_matplotlib_greyscale_colors_are_not_evaluated_as_colors(
4545
self, sdata_blobs: SpatialData, colname: str
4646
):
47-
sdata_blobs["table"].obs["region"] = ["blobs_polygons"] * sdata_blobs["table"].n_obs
47+
sdata_blobs["table"].obs["region"] = pd.Categorical(["blobs_polygons"] * sdata_blobs["table"].n_obs)
4848
sdata_blobs["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons"
4949
sdata_blobs.shapes["blobs_polygons"][colname] = [1, 2, 3, 5, 20]
5050
sdata_blobs.pl.render_shapes("blobs_polygons", color=colname).pl.show()

0 commit comments

Comments
 (0)