[docs]classVptreeParameters(Parameters):"""Parameters for the vantage point (VP) tree algorithm."""
[docs]def__init__(self,distance:Literal["Euclidean","Manhattan","Cosine"]="Euclidean",):""" Args: distance: Distance metric for index construction and search. This should be one of ``Euclidean``, ``Manhattan`` or ``Cosine``. """self.distance=distance
@propertydefdistance(self)->str:"""Distance metric, see :meth:`~__init__()`."""returnself._distance@distance.setterdefdistance(self,distance:str):""" Args: distance: Distance metric, see :meth:`~__init__()`. """ifdistancenotin["Euclidean","Manhattan","Cosine"]:raiseValueError("unsupported 'distance'")self._distance=distance
[docs]classVptreeIndex(GenericIndex):"""A prebuilt index for the vantage point tree algorithm, created by :py:func:`~knncolle.define_builder.define_builder` with a :py:class:`~knncolle.vptree.VptreeParameters` instance. """
[docs]def__init__(self,ptr):""" Args: ptr: Address of a ``knncolle_py::WrappedPrebuilt`` containing a VP tree search index, allocated in C++. """super().__init__(ptr)