@@ -28,12 +28,12 @@ def add_annotation(self, annotation):
2828 self .annotations [annotation .id ] = annotation
2929
3030 def get (self , id ):
31- # type:(int) -> Annotation
31+ # type:(int|str ) -> Annotation
3232 """
3333 Retrieve an annotation by its ID.
3434
3535 Args:
36- id (int): The ID of the annotation to retrieve.
36+ id (int|str ): The ID of the annotation to retrieve.
3737
3838 Returns:
3939 The annotation corresponding to the provided ID.
@@ -76,7 +76,7 @@ def __get_neighbors_radius(self):
7676 return radius
7777
7878 def __fetch_neighbors (self , id , radius = 1 ):
79- # type:(int, int) -> list[tuple[float, Annotation]]
79+ # type:(int|str , int) -> list[tuple[float, Annotation]]
8080 radius = radius * self .__get_neighbors_radius ()
8181 neighbors = self .tree .get_all_in_range (
8282 (self .annotations [id ].x_mid , self .annotations [id ].y_mid ), radius )
@@ -116,12 +116,12 @@ def __fetching_ann_in_range(self, result_dict, min_angle, max_angle, result_lst)
116116 return result_lst
117117
118118 def neighbors_wa (self , id , radius = 1 , amin = None , amax = None ):
119- # type:(int, int, float, float) -> list[dict]
119+ # type:(int|str , int, float, float) -> list[dict]
120120 """
121121 Retrieves neighboring elements within a specified angle range around a given element.
122122
123123 Args:
124- id (int): The identifier of the central element.
124+ id (int|str ): The identifier of the central element.
125125 radius (float, optional): The radius within which to search for neighbors. Defaults to 1.
126126 amin (min_angle) (float, optional): The minimum angle in degree. Defaults to None.
127127 amax (max_angle) (float, optional): The maximum angle in degree. Defaults to None.
@@ -150,14 +150,14 @@ def neighbors_wa(self, id, radius=1, amin=None, amax=None):
150150 return result_lst
151151
152152 def neighbors (self , id , radius = 1 ):
153- # type:(int, int) -> list[dict]
153+ # type:(int|str , int) -> list[dict]
154154 """
155155 Finds neighboring annotations within a specified radius of a given annotation.(Radius specified is taken as a square rather than a circle)
156156
157157 Uses a Vantage Point Tree (VPTree) to efficiently find annotations within the specified radius.
158158
159159 Args:
160- id (int): The ID of the annotation.
160+ id (int|str ): The ID of the annotation.
161161 radius (float, optional): The relative radius within which to search. Defaults to 1.
162162 If a value less than 1 is provided, it's multiplied by an internal factor.
163163
@@ -189,14 +189,14 @@ def neighbors(self, id, radius=1):
189189 return result_lst
190190
191191 def TBLR (self , id , radius = 1 , overlap = 0.5 ):
192- # type:(int, int, float) -> (dict[str, int | bool] | str)
192+ # type:(int|str , int, float) -> (dict[str, int | bool] | str)
193193 """
194194 Computes top, bottom, left, and right connections for a given annotation within a specified radius.
195195
196196 Finds neighboring annotations within the radius, calculates connections based on overlap percentage, and returns the connections as a dictionary.
197197
198198 Args:
199- - id (int): The ID of the annotation.
199+ - id (int|str ): The ID of the annotation.
200200 - radius (float, optional): The radius within which to search for neighboring annotations. Defaults to 1.
201201 - overlap (float, optional): The overlap percentage used to compute connections. Defaults to 0.5.
202202
0 commit comments