From 9407ce50506aa78f033144ccc6d140090bd3c465 Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Sat, 26 Apr 2025 08:25:19 -0700 Subject: [PATCH] Change proxy typehint to the classname --- src/spatialfeatureexperiment/sfe.py | 42 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/spatialfeatureexperiment/sfe.py b/src/spatialfeatureexperiment/sfe.py index 8535722..5a1dfd5 100644 --- a/src/spatialfeatureexperiment/sfe.py +++ b/src/spatialfeatureexperiment/sfe.py @@ -451,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) -> "ProxySpatialFeatureExperiment": + def set_unit(self, unit: str, in_place: bool = False) -> "SpatialFeatureExperiment": """Set the coordinate unit. Args: @@ -459,10 +459,10 @@ def set_unit(self, unit: str, in_place: bool = False) -> "ProxySpatialFeatureExp New unit ('full_res_image_pixel' or 'micron'). in_place: - Whether to modify the ``ProxySpatialFeatureExperiment`` in place. Defaults to False. + Whether to modify the ``SpatialFeatureExperiment`` in place. Defaults to False. Returns: - A modified ``ProxySpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. + A modified ``SpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. """ if unit not in ("full_res_image_pixel", "micron"): raise ValueError("unit must be 'full_res_image_pixel' or 'micron'") @@ -503,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 - ) -> "ProxySpatialFeatureExperiment": + ) -> "SpatialFeatureExperiment": """Set column geometries. Args: @@ -511,10 +511,10 @@ def set_col_geometries( New column geometries. in_place: - Whether to modify the ``ProxySpatialFeatureExperiment`` in place. Defaults to False. + Whether to modify the ``SpatialFeatureExperiment`` in place. Defaults to False. Returns: - A modified ``ProxySpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. + A modified ``SpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. """ _geoms = _sanitize_geomertries(geometries=geometries) _validate_geometries(_geoms, "col_geometries") @@ -525,7 +525,7 @@ def set_col_geometries( def set_row_geometries( self, geometries: Dict[str, gpd.GeoDataFrame], in_place: bool = False - ) -> "ProxySpatialFeatureExperiment": + ) -> "SpatialFeatureExperiment": """Set row geometries. Args: @@ -533,10 +533,10 @@ def set_row_geometries( New row geometries. in_place: - Whether to modify the ``ProxySpatialFeatureExperiment`` in place. Defaults to False. + Whether to modify the ``SpatialFeatureExperiment`` in place. Defaults to False. Returns: - A modified ``ProxySpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. + A modified ``SpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. """ _geoms = _sanitize_geomertries(geometries=geometries) _validate_geometries(_geoms, "row_geometries") @@ -547,7 +547,7 @@ def set_row_geometries( def set_annot_geometries( self, geometries: Dict[str, gpd.GeoDataFrame], in_place: bool = False - ) -> "ProxySpatialFeatureExperiment": + ) -> "SpatialFeatureExperiment": """Set annotation geometries. Args: @@ -555,10 +555,10 @@ def set_annot_geometries( New annotation geometries. in_place: - Whether to modify the ``ProxySpatialFeatureExperiment`` in place. Defaults to False. + Whether to modify the ``SpatialFeatureExperiment`` in place. Defaults to False. Returns: - A modified ``ProxySpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. + A modified ``SpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. """ _geoms = _sanitize_geomertries(geometries=geometries) @@ -619,9 +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 - ) -> "ProxySpatialFeatureExperiment": + def set_spatial_graphs(self, graphs: Optional[BiocFrame], in_place: bool = False) -> "SpatialFeatureExperiment": """Set spatial neighborhood graphs. Args: @@ -629,10 +627,10 @@ def set_spatial_graphs( New spatial graphs as `BiocFrame`. in_place: - Whether to modify the ``ProxySpatialFeatureExperiment`` in place. Defaults to False. + Whether to modify the ``SpatialFeatureExperiment`` in place. Defaults to False. Returns: - A modified ``ProxySpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. + A modified ``SpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. """ _graphs = _sanitize_spatial_graphs(graphs, list(set(self.get_column_data().get_column("sample_id")))) _validate_graph_structure(_graphs) @@ -664,7 +662,7 @@ def get_slice( self, rows: Optional[Union[str, int, bool, List]] = None, columns: Optional[Union[str, int, bool, List]] = None, - ) -> "ProxySpatialFeatureExperiment": + ) -> "SpatialFeatureExperiment": """Get a slice of the experiment. Args: @@ -675,7 +673,7 @@ def get_slice( Column indices/names to select. Returns: - Sliced ProxySpatialFeatureExperiment. + Sliced SpatialFeatureExperiment. """ sfe = super().get_slice(rows=rows, columns=columns) @@ -752,7 +750,7 @@ def set_column_data( cols: Optional[BiocFrame], replace_column_names: bool = False, in_place: bool = False, - ) -> "ProxySpatialFeatureExperiment": + ) -> "SpatialFeatureExperiment": """Override: Set sample data. Args: @@ -769,10 +767,10 @@ def set_column_data( new object. Defaults to False. in_place: - Whether to modify the ``ProxySpatialFeatureExperiment`` in place. Defaults to False. + Whether to modify the ``SpatialFeatureExperiment`` in place. Defaults to False. Returns: - A modified ``ProxySpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. + A modified ``SpatialFeatureExperiment`` object, either as a copy of the original or as a reference to the (in-place-modified) original. """ cols = _sanitize_frame(cols, num_rows=self.shape[1]) if "sample_id" not in cols.columns: