diff --git a/README.md b/README.md index 08a734cb89..a932b7dd41 100755 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ from cuvs.neighbors import cagra dataset = load_data() index_params = cagra.IndexParams() -index = cagra.build_index(build_params, dataset) +index = cagra.build(build_params, dataset) ``` ### C++ API diff --git a/docs/source/python_api/neighbors_cagra.rst b/docs/source/python_api/neighbors_cagra.rst index 6f64f77635..09b2e2694c 100644 --- a/docs/source/python_api/neighbors_cagra.rst +++ b/docs/source/python_api/neighbors_cagra.rst @@ -28,7 +28,7 @@ Index Index build ########### -.. autofunction:: cuvs.neighbors.cagra.build_index +.. autofunction:: cuvs.neighbors.cagra.build Index search ############ diff --git a/docs/source/working_with_ann_indexes_python.rst b/docs/source/working_with_ann_indexes_python.rst index c075deaea4..b2ab47a854 100644 --- a/docs/source/working_with_ann_indexes_python.rst +++ b/docs/source/working_with_ann_indexes_python.rst @@ -16,7 +16,7 @@ Building an index dataset = load_data() index_params = cagra.IndexParams() - index = cagra.build_index(build_params, dataset) + index = cagra.build(build_params, dataset) Searching an index diff --git a/python/cuvs/cuvs/neighbors/cagra/__init__.py b/python/cuvs/cuvs/neighbors/cagra/__init__.py index dd87a644aa..889425f950 100644 --- a/python/cuvs/cuvs/neighbors/cagra/__init__.py +++ b/python/cuvs/cuvs/neighbors/cagra/__init__.py @@ -18,7 +18,7 @@ Index, IndexParams, SearchParams, - build_index, + build, load, save, search, @@ -29,7 +29,7 @@ "Index", "IndexParams", "SearchParams", - "build_index", + "build", "load", "save", "search", diff --git a/python/cuvs/cuvs/neighbors/cagra/cagra.pyx b/python/cuvs/cuvs/neighbors/cagra/cagra.pyx index 3cdff37276..f940ab8bfd 100644 --- a/python/cuvs/cuvs/neighbors/cagra/cagra.pyx +++ b/python/cuvs/cuvs/neighbors/cagra/cagra.pyx @@ -15,6 +15,8 @@ # # cython: language_level=3 +import warnings + import numpy as np cimport cuvs.common.cydlpack @@ -231,7 +233,7 @@ cdef class Index: @auto_sync_resources -def build_index(IndexParams index_params, dataset, resources=None): +def build(IndexParams index_params, dataset, resources=None): """ Build the CAGRA index from the dataset for efficient search. @@ -268,7 +270,7 @@ def build_index(IndexParams index_params, dataset, resources=None): >>> dataset = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) >>> build_params = cagra.IndexParams(metric="sqeuclidean") - >>> index = cagra.build_index(build_params, dataset) + >>> index = cagra.build(build_params, dataset) >>> distances, neighbors = cagra.search(cagra.SearchParams(), ... index, dataset, ... k) @@ -301,6 +303,12 @@ def build_index(IndexParams index_params, dataset, resources=None): return idx +def build_index(IndexParams index_params, dataset, resources=None): + warnings.warn("cagra.build_index is deprecated, use cagra.build instead", + FutureWarning) + return build(index_params, dataset, resources=resources) + + cdef class SearchParams: """ CAGRA search parameters @@ -501,7 +509,7 @@ def search(SearchParams search_params, >>> dataset = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) >>> # Build index - >>> index = cagra.build_index(cagra.IndexParams(), dataset) + >>> index = cagra.build(cagra.IndexParams(), dataset) >>> # Search using the built index >>> queries = cp.random.random_sample((n_queries, n_features), ... dtype=cp.float32) @@ -596,7 +604,7 @@ def save(filename, Index index, bool include_dataset=True, resources=None): >>> dataset = cp.random.random_sample((n_samples, n_features), ... dtype=cp.float32) >>> # Build index - >>> index = cagra.build_index(cagra.IndexParams(), dataset) + >>> index = cagra.build(cagra.IndexParams(), dataset) >>> # Serialize and deserialize the cagra index built >>> cagra.save("my_index.bin", index) >>> index_loaded = cagra.load("my_index.bin") diff --git a/python/cuvs/cuvs/test/test_cagra.py b/python/cuvs/cuvs/test/test_cagra.py index 15711c854d..38d0d18657 100644 --- a/python/cuvs/cuvs/test/test_cagra.py +++ b/python/cuvs/cuvs/test/test_cagra.py @@ -54,9 +54,9 @@ def run_cagra_build_search_test( ) if array_type == "device": - index = cagra.build_index(build_params, dataset_device) + index = cagra.build(build_params, dataset_device) else: - index = cagra.build_index(build_params, dataset) + index = cagra.build(build_params, dataset) if not add_data_on_build: dataset_1 = dataset[: n_rows // 2, :] @@ -198,7 +198,7 @@ def test_save_load(dtype, include_dataset): dataset_device = device_ndarray(dataset) build_params = cagra.IndexParams() - index = cagra.build_index(build_params, dataset_device) + index = cagra.build(build_params, dataset_device) assert index.trained filename = "my_index.bin"