Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 "