@@ -26,15 +26,15 @@ class Definition:
2626def instantiate_algorithm (definition : Definition ) -> BaseANN :
2727 """
2828 Create a `BaseANN` from a definition.
29-
29+
3030 Args:
3131 definition (Definition): An object containing information about the algorithm.
3232
3333 Returns:
3434 BaseANN: Instantiated algorithm
3535
3636 Note:
37- The constructors for the algorithm definition are generally located at
37+ The constructors for the algorithm definition are generally located at
3838 ann_benchmarks/algorithms/*/module.py.
3939 """
4040 print (f"Trying to instantiate { definition .module } .{ definition .constructor } ({ definition .arguments } )" )
@@ -54,7 +54,7 @@ def algorithm_status(definition: Definition) -> InstantiationStatus:
5454 """
5555 Determine the instantiation status of the algorithm based on its python module and constructor.
5656
57- Attempts to find the Python class constructor based on the definition's module path and
57+ Attempts to find the Python class constructor based on the definition's module path and
5858 constructor name.
5959
6060 Args:
@@ -107,7 +107,7 @@ def _generate_combinations(args: Union[List[Any], Dict[Any, Any]]) -> List[Union
107107def _substitute_variables (arg : Any , vs : Dict [str , Any ]) -> Any :
108108 """
109109 Substitutes any string variables present in the argument structure with provided values.
110-
110+
111111 Support for nested substitution in the case `arg` is a List or Dict.
112112
113113 Args:
@@ -164,8 +164,8 @@ def _get_definitions(base_dir: str = "ann_benchmarks/algorithms") -> List[Dict[s
164164
165165def _get_algorithm_definitions (point_type : str , distance_metric : str , base_dir : str = "ann_benchmarks/algorithms" ) -> Dict [str , Dict [str , Any ]]:
166166 """Get algorithm definitions for a specific point type and distance metric.
167-
168- A specific algorithm folder can have multiple algorithm definitions for a given point type and
167+
168+ A specific algorithm folder can have multiple algorithm definitions for a given point type and
169169 metric. For example, `ann_benchmarks.algorithms.nmslib` has two definitions for euclidean float
170170 data: specifically `SW-graph(nmslib)` and `hnsw(nmslib)`, even though the module is named nmslib.
171171
@@ -180,7 +180,7 @@ def _get_algorithm_definitions(point_type: str, distance_metric: str, base_dir:
180180 "disabled": false,
181181 "docker_tag": ann-benchmarks-nmslib,
182182 ...
183- },
183+ },
184184 'SW-graph(nmslib)': {
185185 "base_args": ['@metric', sw-graph],
186186 "constructor": NmslibReuseIndex,
@@ -209,9 +209,9 @@ def _get_algorithm_definitions(point_type: str, distance_metric: str, base_dir:
209209def list_algorithms (base_dir : str = "ann_benchmarks/algorithms" ) -> None :
210210 """
211211 Output (to stdout), a list of all algorithms, with their supported point types and metrics.
212-
212+
213213 Args:
214- base_dir (str, optional): The base directory where the algorithms are stored.
214+ base_dir (str, optional): The base directory where the algorithms are stored.
215215 Defaults to "ann_benchmarks/algorithms".
216216 """
217217 all_configs = _get_definitions (base_dir )
@@ -240,7 +240,7 @@ def list_algorithms(base_dir: str = "ann_benchmarks/algorithms") -> None:
240240
241241def generate_arg_combinations (run_group : Dict [str , Any ], arg_type : str ) -> List :
242242 """Generate combinations of arguments from a run group for a specific argument type.
243-
243+
244244 Args:
245245 run_group (Dict[str, Any]): The run group containing argument definitions.
246246 arg_type (str): The type of argument group to generate combinations for.
@@ -266,10 +266,10 @@ def generate_arg_combinations(run_group: Dict[str, Any], arg_type: str) -> List:
266266
267267
268268def prepare_args (run_group : Dict [str , Any ]) -> List :
269- """For an Algorithm's run group, prepare arguments.
270-
269+ """For an Algorithm's run group, prepare arguments.
270+
271271 An `arg_groups` is preferenced over an `args` key.
272-
272+
273273 Args:
274274 run_group (Dict[str, Any]): The run group containing argument definitions.
275275
@@ -287,7 +287,7 @@ def prepare_args(run_group: Dict[str, Any]) -> List:
287287
288288def prepare_query_args (run_group : Dict [str , Any ]) -> List :
289289 """For an algorithm's run group, prepare query args/ query arg groups.
290-
290+
291291 Args:
292292 run_group (Dict[str, Any]): The run group containing argument definitions.
293293
@@ -303,28 +303,28 @@ def prepare_query_args(run_group: Dict[str, Any]) -> List:
303303def create_definitions_from_algorithm (name : str , algo : Dict [str , Any ], dimension : int , distance_metric : str = "euclidean" , count : int = 10 ) -> List [Definition ]:
304304 """
305305 Create definitions from an indvidual algorithm. An algorithm (e.g. annoy) can have multiple
306- definitions based on various run groups (see config.ymls for clear examples).
307-
306+ definitions based on various run groups (see config.ymls for clear examples).
307+
308308 Args:
309309 name (str): Name of the algorithm.
310310 algo (Dict[str, Any]): Dictionary with algorithm parameters.
311311 dimension (int): Dimension of the algorithm.
312312 distance_metric (str, optional): Distance metric used by the algorithm. Defaults to "euclidean".
313313 count (int, optional): Count of the definitions to be created. Defaults to 10.
314-
314+
315315 Raises:
316316 Exception: If the algorithm does not define "docker_tag", "module" or "constructor" properties.
317-
317+
318318 Returns:
319319 List[Definition]: A list of definitions created from the algorithm.
320320 """
321321 required_properties = ["docker_tag" , "module" , "constructor" ]
322322 missing_properties = [prop for prop in required_properties if prop not in algo ]
323323 if missing_properties :
324324 raise ValueError (f"Algorithm { name } is missing the following properties: { ', ' .join (missing_properties )} " )
325-
325+
326326 base_args = algo .get ("base_args" , [])
327-
327+
328328 definitions = []
329329 for run_group in algo ["run_groups" ].values ():
330330 args = prepare_args (run_group )
@@ -340,7 +340,7 @@ def create_definitions_from_algorithm(name: str, algo: Dict[str, Any], dimension
340340
341341 vs = {"@count" : count , "@metric" : distance_metric , "@dimension" : dimension }
342342 current_args = [_substitute_variables (arg , vs ) for arg in current_args ]
343-
343+
344344 definitions .append (
345345 Definition (
346346 algorithm = name ,
@@ -373,6 +373,6 @@ def get_definitions(
373373 definitions .extend (
374374 create_definitions_from_algorithm (name , algo , dimension , distance_metric , count )
375375 )
376-
376+
377377
378378 return definitions
0 commit comments