From f6dcb5a2c18f478800d806fa9fd7f80542bcadce Mon Sep 17 00:00:00 2001 From: Luca Marconato Date: Wed, 13 Mar 2024 01:06:59 +0100 Subject: [PATCH 1/2] removed int contraint for instance_key column --- src/spatialdata/models/models.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/spatialdata/models/models.py b/src/spatialdata/models/models.py index f84bf4d5..8d77f184 100644 --- a/src/spatialdata/models/models.py +++ b/src/spatialdata/models/models.py @@ -20,7 +20,6 @@ from multiscale_spatial_image.multiscale_spatial_image import MultiscaleSpatialImage from multiscale_spatial_image.to_multiscale.to_multiscale import Methods from pandas import CategoricalDtype -from pandas.errors import IntCastingNaNError from shapely._geometry import GeometryType from shapely.geometry import MultiPolygon, Point, Polygon from shapely.geometry.collection import GeometryCollection @@ -867,14 +866,14 @@ def parse( adata.obs[region_key] = pd.Categorical(adata.obs[region_key]) if instance_key is None: raise ValueError("`instance_key` must be provided.") - if adata.obs[instance_key].dtype != int: - try: - warnings.warn( - f"Converting `{cls.INSTANCE_KEY}: {instance_key}` to integer dtype.", UserWarning, stacklevel=2 - ) - adata.obs[instance_key] = adata.obs[instance_key].astype(int) - except IntCastingNaNError as exc: - raise ValueError("Values within table.obs[] must be able to be coerced to int dtype.") from exc + # if adata.obs[instance_key].dtype != int: + # try: + # warnings.warn( + # f"Converting `{cls.INSTANCE_KEY}: {instance_key}` to integer dtype.", UserWarning, stacklevel=2 + # ) + # adata.obs[instance_key] = adata.obs[instance_key].astype(int) + # except IntCastingNaNError as exc: + # raise ValueError("Values within table.obs[] must be able to be coerced to int dtype.") from exc grouped = adata.obs.groupby(region_key, observed=True) grouped_size = grouped.size() From c10d0851181ea0cc6cbb25dd2d1d79319119d1c2 Mon Sep 17 00:00:00 2001 From: Luca Marconato Date: Wed, 13 Mar 2024 01:07:53 +0100 Subject: [PATCH 2/2] removed comment --- src/spatialdata/models/models.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/spatialdata/models/models.py b/src/spatialdata/models/models.py index 8d77f184..7c4a4979 100644 --- a/src/spatialdata/models/models.py +++ b/src/spatialdata/models/models.py @@ -866,14 +866,6 @@ def parse( adata.obs[region_key] = pd.Categorical(adata.obs[region_key]) if instance_key is None: raise ValueError("`instance_key` must be provided.") - # if adata.obs[instance_key].dtype != int: - # try: - # warnings.warn( - # f"Converting `{cls.INSTANCE_KEY}: {instance_key}` to integer dtype.", UserWarning, stacklevel=2 - # ) - # adata.obs[instance_key] = adata.obs[instance_key].astype(int) - # except IntCastingNaNError as exc: - # raise ValueError("Values within table.obs[] must be able to be coerced to int dtype.") from exc grouped = adata.obs.groupby(region_key, observed=True) grouped_size = grouped.size()