1515from copy import deepcopy
1616from typing import Any , Generic , Iterator , Literal , Type , TypeVar
1717
18- if sys .version_info >= (3 , 11 ):
19- # Use Self from typing module in Python 3.11+
20- from typing import Self
21- else :
22- # Use Self from typing_extensions module in Python < 3.11
23- from typing_extensions import Self
24-
2518import guidata .dataset as gds
2619import numpy as np
2720import pandas as pd
3124from sigima_ .algorithms import coordinates
3225from sigima_ .algorithms .datatypes import is_integer_dtype
3326
27+ if sys .version_info >= (3 , 11 ):
28+ # Use Self from typing module in Python 3.11+
29+ from typing import Self
30+ else :
31+ # Use Self from typing_extensions module in Python < 3.11
32+ from typing_extensions import Self
33+
3434ROI_KEY = "_roi_"
3535
3636
@@ -624,8 +624,6 @@ class BaseObjMeta(abc.ABCMeta, gds.DataSetMeta):
624624class NoDefaultOption :
625625 """Marker class for metadata option without default value"""
626626
627- pass
628-
629627
630628class BaseObj (Generic [TypeROI ], metaclass = BaseObjMeta ):
631629 """Object (signal/image) interface"""
@@ -876,7 +874,8 @@ def transform_coords(
876874 self ,
877875 coords : np .ndarray ,
878876 orig : BaseObj [TypeROI ],
879- func : Callable ,
877+ func : Callable [[BaseObj [TypeROI ], BaseObj [TypeROI ], np .ndarray ], None ]
878+ | Callable [[BaseObj [TypeROI ], BaseObj [TypeROI ], np .ndarray , gds .DataSet ], None ],
880879 param : gds .DataSet | None ,
881880 ) -> None :
882881 """Transform coordinates
@@ -893,7 +892,11 @@ def transform_coords(
893892 func (self , orig , coords , param )
894893
895894 def transform_shapes (
896- self , orig : BaseObj [TypeROI ], func : Callable , param : gds .DataSet | None = None
895+ self ,
896+ orig : BaseObj [TypeROI ],
897+ func : Callable [[BaseObj [TypeROI ], BaseObj [TypeROI ], np .ndarray ], None ]
898+ | Callable [[BaseObj [TypeROI ], BaseObj [TypeROI ], np .ndarray , gds .DataSet ], None ],
899+ param : gds .DataSet | None = None ,
897900 ) -> None :
898901 """Apply transform function to result shape / annotations coordinates.
899902
0 commit comments