Skip to content

Commit

Permalink
switch to helper for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Intron7 committed Dec 6, 2024
1 parent 4df1309 commit 62e5a61
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rapids_singlecell/preprocessing/_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

from rapids_singlecell.tools._utils import _choose_representation

CUVS_SWITCH = parse_version(pylibraft.__version__) > parse_version("24.10")

def _cuvs_switch():
return parse_version(pylibraft.__version__) > parse_version("24.10")


if TYPE_CHECKING:
from collections.abc import Mapping
Expand Down Expand Up @@ -87,7 +90,7 @@ def _brute_knn(
def _cagra_knn(
X: cp.ndarray, Y: cp.ndarray, k: int, metric: _Metrics, metric_kwds: Mapping
) -> tuple[cp.ndarray, cp.ndarray]:
if not CUVS_SWITCH:
if not _cuvs_switch():
try:
from pylibraft.neighbors import cagra
except ImportError:
Expand Down Expand Up @@ -138,7 +141,7 @@ def _cagra_knn(
def _ivf_flat_knn(
X: cp.ndarray, Y: cp.ndarray, k: int, metric: _Metrics, metric_kwds: Mapping
) -> tuple[cp.ndarray, cp.ndarray]:
if not CUVS_SWITCH:
if not _cuvs_switch():
from pylibraft.neighbors import ivf_flat

resources = DeviceResources()
Expand Down Expand Up @@ -170,7 +173,7 @@ def _ivf_flat_knn(
def _ivf_pq_knn(
X: cp.ndarray, Y: cp.ndarray, k: int, metric: _Metrics, metric_kwds: Mapping
) -> tuple[cp.ndarray, cp.ndarray]:
if not CUVS_SWITCH:
if not _cuvs_switch():
from pylibraft.neighbors import ivf_pq

resources = DeviceResources()
Expand Down

0 comments on commit 62e5a61

Please sign in to comment.