code: def test_build_and_search_index(setup):
      # for now, test SquaredEuclidean and Euclidean only,
      # TODO: add more tests for "Canberra", "Chebyshev"
      #  "Manhattan" when ready
  
      # L2 space
      # params
      doc_count, query_count, dimension, topk = 200, 15, 5, 3
      threads, column_number, row_number = 4, 2, 2
      measure_name_lists = ["SquaredEuclidean", "Euclidean"]
      index_builder_lists = [
          "SsgBuilder",
          "HnswBuilder",
          "LinearBuilder",
          "ClusteringBuilder",
          "GcBuilder",
          "QcBuilder",
      ]
      builder_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.builder.max_document_count": doc_count},
          {"proxima.gc.builder.centroid_count": "16"},
          {"proxima.qc.builder.centroid_count": "16"},
      ]
      index_searcher_lists = [
          "SsgSearcher",
          "HnswSearcher",
          "LinearSearcher",
          "ClusteringSearcher",
          "GcSearcher",
          "QcSearcher",
      ]
      searcher_params = {}
      index_converter, index_converter_params = None, {}
      index_reformer, index_reformer_params = "", {}
  
      # data
      doc, query = gen_data(
          doc_count=doc_count,
          query_count=query_count,
          dimension=dimension,
      )
  
      # test
      for i, index_builder in enumerate(index_builder_lists):
          for measure_name in measure_name_lists:
              consistency_checking(
                  doc=doc,
                  query=query,
                  dimension=dimension,
                  topk=topk,
                  threads=threads,
                  measure_name=measure_name,
                  column_number=column_number,
                  row_number=row_number,
                  index_builder=index_builder,
                  builder_params=builder_params_lists[i],
                  index_converter=index_converter,
                  index_converter_params=index_converter_params,
                  index_searcher=index_searcher_lists[i],
                  searcher_params=searcher_params,
                  index_reformer=index_reformer,
                  index_reformer_params=index_reformer_params,
              )
  
      # L2 space with HalfFloatConverter
      # params
      doc_count, query_count, dimension, topk = 200, 15, 5, 3
      threads, column_number, row_number = 4, 2, 2
      measure_name_lists = ["SquaredEuclidean", "Euclidean"]
      index_builder_lists = [
          "SsgBuilder",
          "HnswBuilder",
          "LinearBuilder",
          "ClusteringBuilder",
          "GcBuilder",
          "QcBuilder",
      ]
      builder_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.builder.max_document_count": doc_count},
          {"proxima.gc.builder.centroid_count": "16"},
          {"proxima.qc.builder.centroid_count": "16"},
      ]
      index_searcher_lists = [
          "SsgSearcher",
          "HnswSearcher",
          "LinearSearcher",
          "ClusteringSearcher",
          "GcSearcher",
          "QcSearcher",
      ]
      index_converter_lists = [
          "HalfFloatConverter",
          "HalfFloatConverter",
          "HalfFloatConverter",
          "HalfFloatConverter",
          "HalfFloatConverter",
          "HalfFloatConverter",
      ]
      searcher_params = {}
      index_converter, index_converter_params = None, {}
      index_reformer, index_reformer_params = "", {}
  
      # data
      doc, query = gen_data(
          doc_count=doc_count,
          query_count=query_count,
          dimension=dimension,
      )
  
      # test
      for i, index_builder in enumerate(index_builder_lists):
          for measure_name in measure_name_lists:
              consistency_checking(
                  doc=doc,
                  query=query,
                  dimension=dimension,
                  topk=topk,
                  threads=threads,
                  measure_name=measure_name,
                  column_number=column_number,
                  row_number=row_number,
                  index_builder=index_builder,
                  builder_params=builder_params_lists[i],
                  index_converter=index_converter_lists[i],
                  index_converter_params=index_converter_params,
                  index_searcher=index_searcher_lists[i],
                  searcher_params=searcher_params,
                  index_reformer=index_reformer,
                  index_reformer_params=index_reformer_params,
                  decimal=7,
              )
  
      # L2 space with Int8QuantizerConverter
      # params
      doc_count, query_count, dimension, topk = 2000, 1, 32, 5
      threads, column_number, row_number = 4, 2, 1
  
      measure_name_lists = ["SquaredEuclidean", "Euclidean"]
      index_builder_lists = [
          "SsgBuilder",
          "HnswBuilder",
          "LinearBuilder",
          "ClusteringBuilder",
          "GcBuilder",
          "QcBuilder",
      ]
      builder_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.builder.max_document_count": doc_count},
          {"proxima.gc.builder.centroid_count": "16"},
          {
              "proxima.qc.builder.centroid_count": "16",
              "proxima.qc.builder.quantizer_class": "Int8QuantizerConverter",
          },
      ]
      index_searcher_lists = [
          "SsgSearcher",
          "HnswSearcher",
          "LinearSearcher",
          "ClusteringSearcher",
          "GcSearcher",
          "QcSearcher",
      ]
      searcher_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.searcher.scan_ratio": 1},
          {"proxima.gc.searcher.scan_ratio": 1},
          {"proxima.qc.searcher.scan_ratio": 1},
      ]
      index_converter_lists = [
          "Int8QuantizerConverter",
          "Int8QuantizerConverter",
          "Int8QuantizerConverter",
          "Int8QuantizerConverter",
          "Int8QuantizerConverter",
          None,
      ]
      index_converter_params = {}
      index_reformer, index_reformer_params = "", {}
  
      # data
      doc, query = gen_data(
          doc_count=doc_count,
          query_count=query_count,
          dimension=dimension,
      )
  
      # test
      for i, index_builder in enumerate(index_builder_lists):
          for measure_name in measure_name_lists:
              consistency_checking(
                  doc=doc,
                  query=query,
                  dimension=dimension,
                  topk=topk,
                  threads=threads,
                  measure_name=measure_name,
                  column_number=column_number,
                  row_number=row_number,
                  index_builder=index_builder,
                  builder_params=builder_params_lists[i],
                  index_converter=index_converter_lists[i],
                  index_converter_params=index_converter_params,
                  index_searcher=index_searcher_lists[i],
                  searcher_params=searcher_params_lists[i],
                  index_reformer=index_reformer,
                  index_reformer_params=index_reformer_params,
                  decimal=2,
              )
  
      # L2 space with Int4QuantizerConverter
      # params
      doc_count, query_count, dimension, topk = 2000, 1, 32, 5
      threads, column_number, row_number = 4, 2, 1
  
      measure_name_lists = ["SquaredEuclidean", "Euclidean"]
      index_builder_lists = [
          "SsgBuilder",
          "HnswBuilder",
          "LinearBuilder",
          "ClusteringBuilder",
          "GcBuilder",
          "QcBuilder",
      ]
      builder_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.builder.max_document_count": doc_count},
          {"proxima.gc.builder.centroid_count": "16"},
          {
              "proxima.qc.builder.centroid_count": "16",
              "proxima.qc.builder.quantizer_class": "Int4QuantizerConverter",
          },
      ]
      index_searcher_lists = [
          "SsgSearcher",
          "HnswSearcher",
          "LinearSearcher",
          "ClusteringSearcher",
          "GcSearcher",
          "QcSearcher",
      ]
      searcher_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.searcher.scan_ratio": 1},
          {"proxima.gc.searcher.scan_ratio": 1},
          {"proxima.qc.searcher.scan_ratio": 1},
      ]
      index_converter_lists = [
          "Int4QuantizerConverter",
          "Int4QuantizerConverter",
          "Int4QuantizerConverter",
          "Int4QuantizerConverter",
          "Int4QuantizerConverter",
          None,
      ]
      index_converter_params = {}
      index_reformer, index_reformer_params = "", {}
  
      # data
      doc, query = gen_data(
          doc_count=doc_count,
          query_count=query_count,
          dimension=dimension,
          dtype=np.float32,
      )
  
      for i, index_builder in enumerate(index_builder_lists):
          for measure_name in measure_name_lists:
              consistency_checking(
                  doc=doc,
                  query=query,
                  dimension=dimension,
                  topk=topk,
                  threads=threads,
                  measure_name=measure_name,
                  column_number=column_number,
                  row_number=row_number,
                  index_builder=index_builder,
                  builder_params=builder_params_lists[i],
                  index_converter=index_converter_lists[i],
                  index_converter_params=index_converter_params,
                  index_searcher=index_searcher_lists[i],
                  searcher_params=searcher_params_lists[i],
                  index_reformer=index_reformer,
                  index_reformer_params=index_reformer_params,
                  decimal=2,
              )
  
      # L2 space with NormalizeConverter
      # params
      doc_count, query_count, dimension, topk = 2000, 1, 32, 5
      threads, column_number, row_number = 4, 2, 1
  
      measure_name_lists = ["SquaredEuclidean", "Euclidean"]
      index_builder_lists = [
          "SsgBuilder",
          "HnswBuilder",
          "LinearBuilder",
          "ClusteringBuilder",
          "GcBuilder",
          "QcBuilder",
      ]
      builder_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.builder.max_document_count": doc_count},
          {"proxima.gc.builder.centroid_count": "16"},
          {"proxima.qc.builder.centroid_count": "16"},
      ]
      index_searcher_lists = [
          "SsgSearcher",
          "HnswSearcher",
          "LinearSearcher",
          "ClusteringSearcher",
          "GcSearcher",
          "QcSearcher",
      ]
      searcher_params_lists = [
          {},
          {},
          {},
          {"proxima.hc.searcher.scan_ratio": 1},
          {"proxima.gc.searcher.scan_ratio": 1},
          {"proxima.qc.searcher.scan_ratio": 1},
      ]
      index_converter_lists = [
          "NormalizeConverter",
          "NormalizeConverter",
          "NormalizeConverter",
          "NormalizeConverter",
          "NormalizeConverter",
          "NormalizeConverter",
      ]
      index_converter_params = {}
      index_reformer, index_reformer_params = "", {}
      # data
      doc, query = gen_data(
          doc_count=doc_count,
          query_count=query_count,
          dimension=dimension,
          dtype=np.float32,
      )
  
      for i, index_builder in enumerate(index_builder_lists):
          for measure_name in measure_name_lists:
              consistency_checking(
                  doc,
                  query,
                  dimension=dimension,
                  topk=topk,
                  threads=threads,
                  measure_name=measure_name,
                  column_number=column_number,
                  row_number=row_number,
                  index_builder=index_builder,
                  builder_params=builder_params_lists[i],
                  index_converter=index_converter_lists[i],
                  index_converter_params=index_converter_params,
                  index_searcher=index_searcher_lists[i],
                  searcher_params=searcher_params_lists[i],
                  index_reformer=index_reformer,
                  index_reformer_params=index_reformer_params,
                  decimal=2,
              )
  
      # InnerProduct space
      # params
      doc_count, query_count, dimension, topk = 200, 15, 5, 2
      threads, column_number, row_number = 4, 2, 2
  
      measure_name_lists = ["InnerProduct"]
      index_builder_lists = [
          "LinearBuilder",
          "QcBuilder",
          "HnswBuilder",
          "SsgBuilder",
          "ClusteringBuilder",
          "GcBuilder",
      ]
      builder_params_lists = [
          {},
          {"proxima.qc.builder.centroid_count": "16"},
          {},
          {},
          {"proxima.hc.builder.max_document_count": doc_count},
          {"proxima.gc.builder.centroid_count": "16"},
      ]
      index_searcher_lists = [
          "LinearSearcher",
          "QcSearcher",
          "HnswSearcher",
          "SsgSearcher",
          "ClusteringSearcher",
          "GcSearcher",
      ]
      index_converter_lists = [
          None,
          None,
          "MipsConverter",
          "MipsConverter",
          "MipsConverter",
          "MipsConverter",
      ]
  
      searcher_params = {}
      index_converter_params = {}
      index_reformer, index_reformer_params = "", {}
  
      # data
      doc, query = gen_data(
          doc_count=doc_count,
          query_count=query_count,
          dimension=dimension,
      )
  
      for i, index_builder in enumerate(index_builder_lists):
          for measure_name in measure_name_lists:
              consistency_checking(
                  doc,
                  query,
                  dimension=dimension,
                  topk=topk,
                  threads=threads,
                  measure_name=measure_name,
                  column_number=column_number,
                  row_number=row_number,
                  index_builder=index_builder,
                  builder_params=builder_params_lists[i],
                  index_converter=index_converter_lists[i],
                  index_converter_params=index_converter_params,
                  index_searcher=index_searcher_lists[i],
                  searcher_params=searcher_params,
                  index_reformer=index_reformer,
                  index_reformer_params=index_reformer_params,
                  decimal=5,
              )
  
file_path: mars/mars/learn/proxima/simple_index/tests/test_simple_index.py
imports: import os
  import tempfile
  import numpy
  import pandas
  import pytest
  from .....None import dataframe
  from .....None import tensor
  from ...core import proxima
  from ..None import build_index, search_index, recall
label_desc: Use image node_id 5 for calling a global function with example usage: test_build_and_search_index(setup) without return types