|
16 | 16 | from spatialdata.transformations._utils import _set_transformations |
17 | 17 |
|
18 | 18 | import spatialdata_plot # noqa: F401 |
19 | | -from tests.conftest import DPI, PlotTester, PlotTesterMeta |
| 19 | +from tests.conftest import DPI, PlotTester, PlotTesterMeta, _viridis_with_under_over |
20 | 20 |
|
21 | 21 | RNG = np.random.default_rng(seed=42) |
22 | 22 | sc.pl.set_rcParams_defaults() |
@@ -456,82 +456,47 @@ def test_plot_can_do_non_matching_table(self, sdata_blobs: SpatialData): |
456 | 456 |
|
457 | 457 | sdata_blobs.pl.render_shapes("blobs_circles", color="instance_id").pl.show() |
458 | 458 |
|
459 | | - def test_plot_can_color_with_norm_no_clipping(self, sdata_blobs: SpatialData): |
460 | | - blob = deepcopy(sdata_blobs) |
461 | | - blob["table"].obs["region"] = "blobs_polygons" |
462 | | - blob["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons" |
463 | | - blob.shapes["blobs_polygons"]["value"] = [1, 2, 3, 4, 5] |
464 | | - cmap = matplotlib.colormaps["viridis"] |
465 | | - cmap.set_under("black") |
466 | | - cmap.set_over("grey") |
467 | | - blob.pl.render_shapes( |
468 | | - element="blobs_polygons", color="value", norm=Normalize(2, 4, clip=False), cmap=cmap |
| 459 | + def test_plot_can_color_with_norm_no_clipping(self, sdata_blobs_shapes_annotated: SpatialData): |
| 460 | + sdata_blobs_shapes_annotated.pl.render_shapes( |
| 461 | + element="blobs_polygons", color="value", norm=Normalize(2, 4, clip=False), cmap=_viridis_with_under_over() |
469 | 462 | ).pl.show() |
470 | 463 |
|
471 | | - def test_plot_datashader_can_color_with_norm_and_clipping(self, sdata_blobs: SpatialData): |
472 | | - blob = deepcopy(sdata_blobs) |
473 | | - blob["table"].obs["region"] = "blobs_polygons" |
474 | | - blob["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons" |
475 | | - blob.shapes["blobs_polygons"]["value"] = [1, 2, 3, 4, 5] |
476 | | - cmap = matplotlib.colormaps["viridis"] |
477 | | - cmap.set_under("black") |
478 | | - cmap.set_over("grey") |
479 | | - blob.pl.render_shapes( |
| 464 | + def test_plot_datashader_can_color_with_norm_and_clipping(self, sdata_blobs_shapes_annotated: SpatialData): |
| 465 | + sdata_blobs_shapes_annotated.pl.render_shapes( |
480 | 466 | element="blobs_polygons", |
481 | 467 | color="value", |
482 | 468 | norm=Normalize(2, 4, clip=True), |
483 | | - cmap=cmap, |
| 469 | + cmap=_viridis_with_under_over(), |
484 | 470 | method="datashader", |
485 | 471 | datashader_reduction="max", |
486 | 472 | ).pl.show() |
487 | 473 |
|
488 | | - def test_plot_datashader_can_color_with_norm_no_clipping(self, sdata_blobs: SpatialData): |
489 | | - blob = deepcopy(sdata_blobs) |
490 | | - blob["table"].obs["region"] = "blobs_polygons" |
491 | | - blob["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons" |
492 | | - blob.shapes["blobs_polygons"]["value"] = [1, 2, 3, 4, 5] |
493 | | - cmap = matplotlib.colormaps["viridis"] |
494 | | - cmap.set_under("black") |
495 | | - cmap.set_over("grey") |
496 | | - blob.pl.render_shapes( |
| 474 | + def test_plot_datashader_can_color_with_norm_no_clipping(self, sdata_blobs_shapes_annotated: SpatialData): |
| 475 | + sdata_blobs_shapes_annotated.pl.render_shapes( |
497 | 476 | element="blobs_polygons", |
498 | 477 | color="value", |
499 | 478 | norm=Normalize(2, 4, clip=False), |
500 | | - cmap=cmap, |
| 479 | + cmap=_viridis_with_under_over(), |
501 | 480 | method="datashader", |
502 | 481 | datashader_reduction="max", |
503 | 482 | ).pl.show() |
504 | 483 |
|
505 | | - def test_plot_datashader_norm_vmin_eq_vmax_without_clip(self, sdata_blobs: SpatialData): |
506 | | - blob = deepcopy(sdata_blobs) |
507 | | - blob["table"].obs["region"] = "blobs_polygons" |
508 | | - blob["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons" |
509 | | - blob.shapes["blobs_polygons"]["value"] = [1, 2, 3, 4, 5] |
510 | | - cmap = matplotlib.colormaps["viridis"] |
511 | | - cmap.set_under("black") |
512 | | - cmap.set_over("grey") |
513 | | - blob.pl.render_shapes( |
| 484 | + def test_plot_datashader_norm_vmin_eq_vmax_without_clip(self, sdata_blobs_shapes_annotated: SpatialData): |
| 485 | + sdata_blobs_shapes_annotated.pl.render_shapes( |
514 | 486 | element="blobs_polygons", |
515 | 487 | color="value", |
516 | 488 | norm=Normalize(3, 3, clip=False), |
517 | | - cmap=cmap, |
| 489 | + cmap=_viridis_with_under_over(), |
518 | 490 | method="datashader", |
519 | 491 | datashader_reduction="max", |
520 | 492 | ).pl.show() |
521 | 493 |
|
522 | | - def test_plot_datashader_norm_vmin_eq_vmax_with_clip(self, sdata_blobs: SpatialData): |
523 | | - blob = deepcopy(sdata_blobs) |
524 | | - blob["table"].obs["region"] = "blobs_polygons" |
525 | | - blob["table"].uns["spatialdata_attrs"]["region"] = "blobs_polygons" |
526 | | - blob.shapes["blobs_polygons"]["value"] = [1, 2, 3, 4, 5] |
527 | | - cmap = matplotlib.colormaps["viridis"] |
528 | | - cmap.set_under("black") |
529 | | - cmap.set_over("grey") |
530 | | - blob.pl.render_shapes( |
| 494 | + def test_plot_datashader_norm_vmin_eq_vmax_with_clip(self, sdata_blobs_shapes_annotated: SpatialData): |
| 495 | + sdata_blobs_shapes_annotated.pl.render_shapes( |
531 | 496 | element="blobs_polygons", |
532 | 497 | color="value", |
533 | 498 | norm=Normalize(3, 3, clip=True), |
534 | | - cmap=cmap, |
| 499 | + cmap=_viridis_with_under_over(), |
535 | 500 | method="datashader", |
536 | 501 | datashader_reduction="max", |
537 | 502 | ).pl.show() |
|
0 commit comments