Skip to content

Commit 74a033b

Browse files
authored
Use warnings (#163)
1 parent 4fb3433 commit 74a033b

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎spatialdata/_core/models.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from functools import singledispatchmethod
66
from pathlib import Path
77
from typing import TYPE_CHECKING, Any, Literal, Optional, Union
8+
from warnings import warn
89

910
import dask.dataframe as dd
1011
import numpy as np
@@ -668,7 +669,7 @@ def parse(
668669
if not adata.obs[region_key].isin(region).all():
669670
raise ValueError(f"`adata.obs[{region_key}]` values do not match with `{cls.REGION_KEY}` values.")
670671
if not is_categorical_dtype(adata.obs[region_key]):
671-
logger.warning(f"Converting `{cls.REGION_KEY_KEY}: {region_key}` to categorical dtype.")
672+
warn(f"Converting `{cls.REGION_KEY_KEY}: {region_key}` to categorical dtype.", UserWarning)
672673
adata.obs[region_key] = pd.Categorical(adata.obs[region_key])
673674
if instance_key is None:
674675
raise ValueError("`instance_key` must be provided if `region` is of type `List`.")

‎spatialdata/_core/transformations.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from abc import ABC, abstractmethod
44
from typing import TYPE_CHECKING, Any, Optional, Union
5+
from warnings import warn
56

67
import numpy as np
78
import xarray as xr
@@ -20,7 +21,6 @@
2021
NgffSequence,
2122
NgffTranslation,
2223
)
23-
from spatialdata._logging import logger
2424
from spatialdata._types import ArrayLike
2525

2626
if TYPE_CHECKING:
@@ -592,10 +592,11 @@ def to_affine_matrix(self, input_axes: tuple[ValidAxis_t, ...], output_axes: tup
592592
)
593593
# asking a representation of the affine transformation that is not using the matrix
594594
if len(set(input_axes).intersection(self.input_axes)) == 0:
595-
logger.warning(
595+
warn(
596596
"Asking a representation of the affine transformation that is not using the matrix: "
597597
f"self.input_axews = {self.input_axes}, self.output_axes = {self.output_axes}, "
598-
f"input_axes = {input_axes}, output_axes = {output_axes}"
598+
f"input_axes = {input_axes}, output_axes = {output_axes}",
599+
UserWarning,
599600
)
600601
m = self._empty_affine_matrix(input_axes, output_axes)
601602
for i_out, ax_out in enumerate(output_axes):

0 commit comments

Comments
 (0)