diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a102035..a6b7c8a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -28,7 +28,7 @@ jobs: test: strategy: matrix: - python: ["3.9", "3.10", "3.11", "3.12"] # , "3.13" + python: ["3.10", "3.11", "3.12", "3.13"] platform: - ubuntu-latest # - macos-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 30e2f15..2e6058d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Version 0.1.0 + +- Migrating changes related to SPE and SCE. + ## Version 0.0.4-0.0.5 - Implement `to_anndata()` to convert from spatial feature experiment to AnnData diff --git a/setup.cfg b/setup.cfg index f4046ee..a787b0f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,7 +49,7 @@ python_requires = >=3.9 # For more information, check out https://semver.org/. install_requires = importlib-metadata; python_version<"3.8" - spatialexperiment>=0.0.12 + spatialexperiment>=0.1.0 pillow geopandas shapely diff --git a/src/spatialfeatureexperiment/sfe.py b/src/spatialfeatureexperiment/sfe.py index ad979f1..3111bf8 100644 --- a/src/spatialfeatureexperiment/sfe.py +++ b/src/spatialfeatureexperiment/sfe.py @@ -1,13 +1,15 @@ -from typing import Any, Dict, List, Optional, Union, Tuple +from __future__ import annotations + +from typing import Any, Dict, List, Optional, Tuple, Union from warnings import warn import biocutils as ut import geopandas as gpd import numpy as np from biocframe import BiocFrame +from libpysal.graph import Graph from spatialexperiment import SpatialExperiment from spatialexperiment._validators import _validate_column_data, _validate_sample_ids -from libpysal.graph import Graph from summarizedexperiment._frameutils import _sanitize_frame from summarizedexperiment.RangedSummarizedExperiment import GRangesOrGRangesList @@ -105,7 +107,7 @@ def __init__( column_data: Optional[BiocFrame] = None, row_names: Optional[List[str]] = None, column_names: Optional[List[str]] = None, - metadata: Optional[dict] = None, + metadata: Optional[Union[Dict[str, Any], ut.NamedList]] = None, reduced_dims: Optional[Dict[str, Any]] = None, main_experiment_name: Optional[str] = None, alternative_experiments: Optional[Dict[str, Any]] = None, @@ -120,7 +122,7 @@ def __init__( annot_geometries: Optional[Dict[str, gpd.GeoDataFrame]] = None, spatial_graphs: Optional[Dict[str, Union[Graph, Any]]] = None, unit: str = "full_res_image_pixel", - validate: bool = True, + _validate: bool = True, **kwargs, ) -> None: """Initialize a spatial feature class. @@ -253,7 +255,7 @@ def __init__( unit: Unit for spatial coordinates ('full_res_image_pixel' or 'micron'). - validate: + _validate: Internal use only. """ # Initialize parent class @@ -273,7 +275,7 @@ def __init__( alternative_experiment_check_dim_names=alternative_experiment_check_dim_names, img_data=img_data, spatial_coords=spatial_coords, - validate=validate, + _validate=_validate, **kwargs, ) @@ -286,7 +288,7 @@ def __init__( ) self._unit = unit - if validate: + if _validate: self._validate() def _validate(self) -> None: @@ -356,6 +358,7 @@ def __deepcopy__(self, memo=None, _nil=[]): annot_geometries=_annot_geometries_copy, spatial_graphs=_spatial_graphs_copy, unit=_unit_copy, + _validate=False, ) def __copy__(self): @@ -384,6 +387,7 @@ def __copy__(self): annot_geometries=self._annot_geometries, spatial_graphs=self._spatial_graphs, unit=self._unit, + _validate=False, ) def copy(self): @@ -447,7 +451,7 @@ def get_unit(self) -> str: """Get the coordinate unit.""" return self._unit - def set_unit(self, unit: str, in_place: bool = False) -> "SpatialFeatureExperiment": + def set_unit(self, unit: str, in_place: bool = False) -> SpatialFeatureExperiment: """Set the coordinate unit. Args: @@ -499,7 +503,7 @@ def get_annot_geometries(self) -> Dict[str, gpd.GeoDataFrame]: def set_col_geometries( self, geometries: Dict[str, gpd.GeoDataFrame], in_place: bool = False - ) -> "SpatialFeatureExperiment": + ) -> SpatialFeatureExperiment: """Set column geometries. Args: @@ -521,7 +525,7 @@ def set_col_geometries( def set_row_geometries( self, geometries: Dict[str, gpd.GeoDataFrame], in_place: bool = False - ) -> "SpatialFeatureExperiment": + ) -> SpatialFeatureExperiment: """Set row geometries. Args: @@ -543,7 +547,7 @@ def set_row_geometries( def set_annot_geometries( self, geometries: Dict[str, gpd.GeoDataFrame], in_place: bool = False - ) -> "SpatialFeatureExperiment": + ) -> SpatialFeatureExperiment: """Set annotation geometries. Args: @@ -615,7 +619,7 @@ def get_spatial_graphs(self) -> Optional[BiocFrame]: """Get spatial neighborhood graphs.""" return self._spatial_graphs - def set_spatial_graphs(self, graphs: Optional[BiocFrame], in_place: bool = False) -> "SpatialFeatureExperiment": + def set_spatial_graphs(self, graphs: Optional[BiocFrame], in_place: bool = False) -> SpatialFeatureExperiment: """Set spatial neighborhood graphs. Args: @@ -658,7 +662,7 @@ def get_slice( self, rows: Optional[Union[str, int, bool, List]] = None, columns: Optional[Union[str, int, bool, List]] = None, - ) -> "SpatialFeatureExperiment": + ) -> SpatialFeatureExperiment: """Get a slice of the experiment. Args: @@ -746,7 +750,7 @@ def set_column_data( cols: Optional[BiocFrame], replace_column_names: bool = False, in_place: bool = False, - ) -> "SpatialFeatureExperiment": + ) -> SpatialFeatureExperiment: """Override: Set sample data. Args: @@ -837,7 +841,7 @@ def from_spatial_experiment( spatial_graphs: BiocFrame = None, spot_diameter: float = None, unit: str = None, - ) -> "SpatialFeatureExperiment": + ) -> SpatialFeatureExperiment: """Coerce a :py:class:~`spatialexperiment.SpatialExperiment` to a `SpatialFeatureExperiment`. Args: