.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/annoy/plot_annoy_cython_0benchmark.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite or Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_annoy_plot_annoy_cython_0benchmark.py: Index (cython) python-api benchmark with examples ================================================= An example showing the :py:class:`~scikitplot.annoy._annoy.Index` class. .. GENERATED FROM PYTHON SOURCE LINES 12-25 .. code-block:: Python import pytest import numpy as np import random; random.seed(0) from pprint import pprint # from annoy import Annoy, AnnoyIndex # from scikitplot.cexternals._annoy import Annoy, AnnoyIndex # from scikitplot.annoy import Annoy, AnnoyIndex, Index from scikitplot.annoy._annoy import Index # print(Index.__doc__) .. GENERATED FROM PYTHON SOURCE LINES 26-84 .. code-block:: Python import subprocess import sys import inspect import joblib from pathlib import Path def get_current_script_dir() -> Path: """ Returns the directory of the current script in a robust way. Returns ------- Path Absolute directory path. Raises ------ RuntimeError If location cannot be determined. """ # Case 1: normal Python execution if "__file__" in globals(): return Path(__file__).resolve().parent # Case 2: fallback for Sphinx-gallery / exec environments frame = inspect.currentframe() if frame is not None: file = inspect.getfile(frame) return Path(file).resolve().parent raise RuntimeError("Cannot determine script directory.") BASE_DIR = get_current_script_dir() PROJECT_ROOT = BASE_DIR.parents[2] # pytest ../../../scikitplot/annoy/_annoy/tests/test_benchmark_dtype_combinations.py::test_benchmark_summary_table cmd = [ sys.executable, "-m", "pytest", # "../../../scikitplot/annoy/_annoy/tests/test_benchmark_dtype_combinations.py::test_benchmark_summary_table", "scikitplot/annoy/_annoy/tests/test_benchmark_dtype_combinations.py::test_benchmark_summary_table", "-vv", ] result = subprocess.run( cmd, cwd=PROJECT_ROOT, check=False, capture_output=True, text=True, ) print("Return code:", result.returncode) print(result.stdout) print(result.stderr) .. rst-class:: sphx-glr-script-out .. code-block:: none Return code: 4 2026-03-20 19:50:23.323484: W scikitplot 133168083962752 __init__.py:82:] ⚠︎ BOOM! :: Error importing scikitplot: you cannot import scikitplot while being in scikitplot source directory; please exit the scikitplot source tree first and relaunch your Python interpreter. ImportError while loading conftest '/home/circleci/repo/scikitplot/conftest.py'. scikitplot/conftest.py:31: in from ._lib import _pep440 scikitplot/_lib/__init__.py:45: in from . import _ccallback_c E ImportError: cannot import name '_ccallback_c' from partially initialized module 'scikitplot._lib' (most likely due to a circular import) (/home/circleci/repo/scikitplot/_lib/__init__.py) .. GENERATED FROM PYTHON SOURCE LINES 85-90 .. tags:: model-workflow: vector-db level: beginner purpose: showcase .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.787 seconds) .. _sphx_glr_download_auto_examples_annoy_plot_annoy_cython_0benchmark.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/scikit-plots/scikit-plots/main?urlpath=lab/tree/notebooks/auto_examples/annoy/plot_annoy_cython_0benchmark.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/annoy/plot_annoy_cython_0benchmark.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_annoy_cython_0benchmark.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_annoy_cython_0benchmark.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_annoy_cython_0benchmark.zip ` .. include:: plot_annoy_cython_0benchmark.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_