@@ -60,6 +60,20 @@ def in_memory(
6060 groundtruth_metadata_types : dict [str , DataType ] | None = None ,
6161 prediction_metadata_types : dict [str , DataType ] | None = None ,
6262 ):
63+ """
64+ Create an in-memory evaluator cache.
65+
66+ Parameters
67+ ----------
68+ batch_size : int, default=10_000
69+ The target number of rows to buffer before writing to the cache. Defaults to 10_000.
70+ datum_metadata_types : dict[str, DataType], optional
71+ Optional datum metadata field definition.
72+ groundtruth_metadata_types : dict[str, DataType], optional
73+ Optional ground truth annotation metadata field definition.
74+ prediction_metadata_types : dict[str, DataType], optional
75+ Optional prediction metadata field definition.
76+ """
6377 datum_metadata_fields = convert_type_mapping_to_fields (
6478 datum_metadata_types
6579 )
@@ -106,6 +120,28 @@ def persistent(
106120 prediction_metadata_types : dict [str , DataType ] | None = None ,
107121 delete_if_exists : bool = False ,
108122 ):
123+ """
124+ Create a persistent file-based evaluator cache.
125+
126+ Parameters
127+ ----------
128+ path : str | Path
129+ Where to store the file-based cache.
130+ batch_size : int, default=10_000
131+ The target number of rows to buffer before writing to the cache. Defaults to 10_000.
132+ rows_per_file : int, default=100_000
133+ The target number of rows to store per cache file. Defaults to 100_000.
134+ compression : str, default="snappy"
135+ The compression methods used when writing cache files.
136+ datum_metadata_types : dict[str, DataType], optional
137+ Optional datum metadata field definition.
138+ groundtruth_metadata_types : dict[str, DataType], optional
139+ Optional ground truth annotation metadata field definition.
140+ prediction_metadata_types : dict[str, DataType], optional
141+ Optional prediction metadata field definition.
142+ delete_if_exists : bool, default=False
143+ Option to delete any pre-exisiting cache at the given path.
144+ """
109145 path = Path (path )
110146 if delete_if_exists and path .exists ():
111147 cls .delete_at_path (path )
@@ -162,6 +198,7 @@ def persistent(
162198 )
163199
164200 def _add_label (self , value : str ) -> int :
201+ """Add a label to the index mapping."""
165202 idx = self ._labels .get (value , None )
166203 if idx is None :
167204 idx = len (self ._labels )
@@ -174,18 +211,7 @@ def _add_data(
174211 detection_ious : list [NDArray [np .float64 ]],
175212 show_progress : bool = False ,
176213 ):
177- """
178- Adds detections to the cache.
179-
180- Parameters
181- ----------
182- detections : list[Detection]
183- A list of Detection objects.
184- detection_ious : list[NDArray[np.float64]]
185- A list of arrays containing IOUs per detection.
186- show_progress : bool, default=False
187- Toggle for tqdm progress bar.
188- """
214+ """Adds detections to the cache."""
189215 disable_tqdm = not show_progress
190216 for detection , ious in tqdm (
191217 zip (detections , detection_ious ), disable = disable_tqdm
@@ -410,6 +436,7 @@ def _rank(
410436 n_labels : int ,
411437 batch_size : int = 1_000 ,
412438 ):
439+ """Perform pair ranking over the detailed cache."""
413440 detailed_reader = self ._detailed_writer .to_reader ()
414441 subset_columns = [
415442 field .name
@@ -484,7 +511,7 @@ def finalize(
484511 index_to_label ,
485512 number_of_groundtruths_per_label ,
486513 info ,
487- ) = self .generate_meta (detailed_reader , index_to_label_override )
514+ ) = self ._generate_meta (detailed_reader , index_to_label_override )
488515 info .datum_metadata_types = self ._datum_metadata_types
489516 info .groundtruth_metadata_types = self ._groundtruth_metadata_types
490517 info .prediction_metadata_types = self ._prediction_metadata_types
0 commit comments