1- from typing import Any , Dict , List , Optional , Union , Tuple
1+ from __future__ import annotations
2+
3+ from typing import Any , Dict , List , Optional , Tuple , Union
24from warnings import warn
35
46import biocutils as ut
57import geopandas as gpd
68import numpy as np
79from biocframe import BiocFrame
10+ from libpysal .graph import Graph
811from spatialexperiment import SpatialExperiment
912from spatialexperiment ._validators import _validate_column_data , _validate_sample_ids
10- from libpysal .graph import Graph
1113from summarizedexperiment ._frameutils import _sanitize_frame
1214from summarizedexperiment .RangedSummarizedExperiment import GRangesOrGRangesList
1315
@@ -105,7 +107,7 @@ def __init__(
105107 column_data : Optional [BiocFrame ] = None ,
106108 row_names : Optional [List [str ]] = None ,
107109 column_names : Optional [List [str ]] = None ,
108- metadata : Optional [dict ] = None ,
110+ metadata : Optional [Union [ Dict [ str , Any ], ut . NamedList ] ] = None ,
109111 reduced_dims : Optional [Dict [str , Any ]] = None ,
110112 main_experiment_name : Optional [str ] = None ,
111113 alternative_experiments : Optional [Dict [str , Any ]] = None ,
@@ -120,7 +122,7 @@ def __init__(
120122 annot_geometries : Optional [Dict [str , gpd .GeoDataFrame ]] = None ,
121123 spatial_graphs : Optional [Dict [str , Union [Graph , Any ]]] = None ,
122124 unit : str = "full_res_image_pixel" ,
123- validate : bool = True ,
125+ _validate : bool = True ,
124126 ** kwargs ,
125127 ) -> None :
126128 """Initialize a spatial feature class.
@@ -253,7 +255,7 @@ def __init__(
253255 unit:
254256 Unit for spatial coordinates ('full_res_image_pixel' or 'micron').
255257
256- validate :
258+ _validate :
257259 Internal use only.
258260 """
259261 # Initialize parent class
@@ -273,7 +275,7 @@ def __init__(
273275 alternative_experiment_check_dim_names = alternative_experiment_check_dim_names ,
274276 img_data = img_data ,
275277 spatial_coords = spatial_coords ,
276- validate = validate ,
278+ _validate = _validate ,
277279 ** kwargs ,
278280 )
279281
@@ -286,7 +288,7 @@ def __init__(
286288 )
287289 self ._unit = unit
288290
289- if validate :
291+ if _validate :
290292 self ._validate ()
291293
292294 def _validate (self ) -> None :
@@ -356,6 +358,7 @@ def __deepcopy__(self, memo=None, _nil=[]):
356358 annot_geometries = _annot_geometries_copy ,
357359 spatial_graphs = _spatial_graphs_copy ,
358360 unit = _unit_copy ,
361+ _validate = False ,
359362 )
360363
361364 def __copy__ (self ):
@@ -384,6 +387,7 @@ def __copy__(self):
384387 annot_geometries = self ._annot_geometries ,
385388 spatial_graphs = self ._spatial_graphs ,
386389 unit = self ._unit ,
390+ _validate = False ,
387391 )
388392
389393 def copy (self ):
@@ -447,7 +451,7 @@ def get_unit(self) -> str:
447451 """Get the coordinate unit."""
448452 return self ._unit
449453
450- def set_unit (self , unit : str , in_place : bool = False ) -> " SpatialFeatureExperiment" :
454+ def set_unit (self , unit : str , in_place : bool = False ) -> SpatialFeatureExperiment :
451455 """Set the coordinate unit.
452456
453457 Args:
@@ -499,7 +503,7 @@ def get_annot_geometries(self) -> Dict[str, gpd.GeoDataFrame]:
499503
500504 def set_col_geometries (
501505 self , geometries : Dict [str , gpd .GeoDataFrame ], in_place : bool = False
502- ) -> " SpatialFeatureExperiment" :
506+ ) -> SpatialFeatureExperiment :
503507 """Set column geometries.
504508
505509 Args:
@@ -521,7 +525,7 @@ def set_col_geometries(
521525
522526 def set_row_geometries (
523527 self , geometries : Dict [str , gpd .GeoDataFrame ], in_place : bool = False
524- ) -> " SpatialFeatureExperiment" :
528+ ) -> SpatialFeatureExperiment :
525529 """Set row geometries.
526530
527531 Args:
@@ -543,7 +547,7 @@ def set_row_geometries(
543547
544548 def set_annot_geometries (
545549 self , geometries : Dict [str , gpd .GeoDataFrame ], in_place : bool = False
546- ) -> " SpatialFeatureExperiment" :
550+ ) -> SpatialFeatureExperiment :
547551 """Set annotation geometries.
548552
549553 Args:
@@ -615,7 +619,7 @@ def get_spatial_graphs(self) -> Optional[BiocFrame]:
615619 """Get spatial neighborhood graphs."""
616620 return self ._spatial_graphs
617621
618- def set_spatial_graphs (self , graphs : Optional [BiocFrame ], in_place : bool = False ) -> " SpatialFeatureExperiment" :
622+ def set_spatial_graphs (self , graphs : Optional [BiocFrame ], in_place : bool = False ) -> SpatialFeatureExperiment :
619623 """Set spatial neighborhood graphs.
620624
621625 Args:
@@ -658,7 +662,7 @@ def get_slice(
658662 self ,
659663 rows : Optional [Union [str , int , bool , List ]] = None ,
660664 columns : Optional [Union [str , int , bool , List ]] = None ,
661- ) -> " SpatialFeatureExperiment" :
665+ ) -> SpatialFeatureExperiment :
662666 """Get a slice of the experiment.
663667
664668 Args:
@@ -746,7 +750,7 @@ def set_column_data(
746750 cols : Optional [BiocFrame ],
747751 replace_column_names : bool = False ,
748752 in_place : bool = False ,
749- ) -> " SpatialFeatureExperiment" :
753+ ) -> SpatialFeatureExperiment :
750754 """Override: Set sample data.
751755
752756 Args:
@@ -837,7 +841,7 @@ def from_spatial_experiment(
837841 spatial_graphs : BiocFrame = None ,
838842 spot_diameter : float = None ,
839843 unit : str = None ,
840- ) -> " SpatialFeatureExperiment" :
844+ ) -> SpatialFeatureExperiment :
841845 """Coerce a :py:class:~`spatialexperiment.SpatialExperiment` to a `SpatialFeatureExperiment`.
842846
843847 Args:
0 commit comments