|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import sys |
4 | | -import warnings |
5 | 4 | from collections import OrderedDict |
6 | 5 | from copy import deepcopy |
7 | 6 | from pathlib import Path |
|
23 | 22 | from xarray import DataArray, DataTree |
24 | 23 |
|
25 | 24 | from spatialdata_plot._accessor import register_spatial_data_accessor |
| 25 | +from spatialdata_plot._logging import logger |
26 | 26 | from spatialdata_plot.pl.render import ( |
27 | 27 | _render_images, |
28 | 28 | _render_labels, |
@@ -272,11 +272,7 @@ def render_shapes( |
272 | 272 | """ |
273 | 273 | # TODO add Normalize object in tutorial notebook and point to that notebook here |
274 | 274 | if "vmin" in kwargs or "vmax" in kwargs: |
275 | | - warnings.warn( |
276 | | - "`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.", |
277 | | - DeprecationWarning, |
278 | | - stacklevel=2, |
279 | | - ) |
| 275 | + logger.warning("`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.") |
280 | 276 | params_dict = _validate_shape_render_params( |
281 | 277 | self._sdata, |
282 | 278 | element=element, |
@@ -423,11 +419,7 @@ def render_points( |
423 | 419 | """ |
424 | 420 | # TODO add Normalize object in tutorial notebook and point to that notebook here |
425 | 421 | if "vmin" in kwargs or "vmax" in kwargs: |
426 | | - warnings.warn( |
427 | | - "`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.", |
428 | | - DeprecationWarning, |
429 | | - stacklevel=2, |
430 | | - ) |
| 422 | + logger.warning("`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.") |
431 | 423 | params_dict = _validate_points_render_params( |
432 | 424 | self._sdata, |
433 | 425 | element=element, |
@@ -544,11 +536,7 @@ def render_images( |
544 | 536 | """ |
545 | 537 | # TODO add Normalize object in tutorial notebook and point to that notebook here |
546 | 538 | if "vmin" in kwargs or "vmax" in kwargs: |
547 | | - warnings.warn( |
548 | | - "`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.", |
549 | | - DeprecationWarning, |
550 | | - stacklevel=2, |
551 | | - ) |
| 539 | + logger.warning("`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.") |
552 | 540 | params_dict = _validate_image_render_params( |
553 | 541 | self._sdata, |
554 | 542 | element=element, |
@@ -679,11 +667,7 @@ def render_labels( |
679 | 667 | """ |
680 | 668 | # TODO add Normalize object in tutorial notebook and point to that notebook here |
681 | 669 | if "vmin" in kwargs or "vmax" in kwargs: |
682 | | - warnings.warn( |
683 | | - "`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.", |
684 | | - DeprecationWarning, |
685 | | - stacklevel=2, |
686 | | - ) |
| 670 | + logger.warning("`vmin` and `vmax` are deprecated. Pass matplotlib `Normalize` object to norm instead.") |
687 | 671 | params_dict = _validate_label_render_params( |
688 | 672 | self._sdata, |
689 | 673 | element=element, |
@@ -918,9 +902,7 @@ def show( |
918 | 902 | # go through tree |
919 | 903 |
|
920 | 904 | for i, cs in enumerate(coordinate_systems): |
921 | | - with warnings.catch_warnings(): |
922 | | - warnings.filterwarnings("ignore", category=UserWarning) |
923 | | - sdata = self._copy() |
| 905 | + sdata = self._copy() |
924 | 906 | _, has_images, has_labels, has_points, has_shapes = ( |
925 | 907 | cs_contents.query(f"cs == '{cs}'").iloc[0, :].values.tolist() |
926 | 908 | ) |
@@ -1000,16 +982,12 @@ def show( |
1000 | 982 | assert isinstance(params_copy.color, str) |
1001 | 983 | colors = sc.get.obs_df(sdata[table], [params_copy.color]) |
1002 | 984 | if isinstance(colors[params_copy.color].dtype, pd.CategoricalDtype): |
1003 | | - # Avoid mutating `.uns` by generating new colors implicitly. |
1004 | | - # Only copy colors if they already exist in `.uns`. |
1005 | | - color_key = f"{params_copy.color}_colors" |
1006 | | - if color_key in sdata[table].uns: |
1007 | | - _maybe_set_colors( |
1008 | | - source=sdata[table], |
1009 | | - target=sdata[table], |
1010 | | - key=params_copy.color, |
1011 | | - palette=params_copy.palette, |
1012 | | - ) |
| 985 | + _maybe_set_colors( |
| 986 | + source=sdata[table], |
| 987 | + target=sdata[table], |
| 988 | + key=params_copy.color, |
| 989 | + palette=params_copy.palette, |
| 990 | + ) |
1013 | 991 |
|
1014 | 992 | rasterize = (params_copy.scale is None) or ( |
1015 | 993 | isinstance(params_copy.scale, str) |
|
0 commit comments