How to use the pynndescent.distances.named_distances function in pynndescent

To help you get started, we’ve selected a few pynndescent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pavlin-policar / openTSNE / openTSNE / nearest_neighbors.py View on Github external
def check_metric(self, metric):
        import pynndescent

        if not np.array_equal(list(pynndescent.distances.named_distances), self.VALID_METRICS):
            warnings.warn(
                "`pynndescent` has recently changed which distance metrics are supported, "
                "and `openTSNE.nearest_neighbors` has not been updated. Please notify the "
                "developers of this change."
            )

        if callable(metric):
            from numba.targets.registry import CPUDispatcher

            if not isinstance(metric, CPUDispatcher):
                warnings.warn(
                    f"`pynndescent` requires callable metrics to be "
                    f"compiled with `numba`, but `{metric.__name__}` is not compiled. "
                    f"`openTSNE.nearest_neighbors.NNDescent` "
                    f"will attempt to compile the function. "
                    f"If this results in an error, then the function may not be "

pynndescent

Nearest Neighbor Descent

BSD-2-Clause
Latest version published 5 months ago

Package Health Score

83 / 100
Full package analysis

Similar packages