# Path: hub_toolbox/io.py
# def load_dexter():
# def check_is_nD_array(arr:np.ndarray, n:int, arr_type=''):
# def check_distance_matrix_shape(D:np.ndarray):
# def check_distance_matrix_shape_fits_vectors(D:np.ndarray, vectors:np.ndarray):
# def check_distance_matrix_shape_fits_labels(D:np.ndarray, classes:np.ndarray):
# def check_vector_matrix_shape_fits_labels(X:np.ndarray, classes:np.ndarray):
# def check_sample_shape_fits(D:np.ndarray, idx:np.ndarray):
# def check_valid_metric_parameter(metric:str):
# def matrix_split(rows, cols, elem_size=8, nr_matrices=4): # pragma: no cover
# def random_sparse_matrix(size, density=0.05):
# def save_csr_matrix(file, matrix):
# def load_csr_matrix(file):
#     def __init__(self, unit='kB'):
#     def _factor(self):
#     def total(self):
#     def used(self):
#     def used_real(self):
#     def shared(self):
#     def buffers(self):
#     def cached(self):
#     def user_free(self):
#     def swap(self):
#     def swap_free(self):
#     def swap_used(self):
#     D = cosine_distance(vectors)
#     S = sparse.rand(size, size, density, 'csr')
# class FreeMemLinux(object): # pragma: no cover


import ctypes
import numpy as np
from functools import partial
from multiprocessing import cpu_count, Pool, RawArray
from hub_toolbox import io
    from hub_toolbox.hubness import hubness
    from hub_toolbox.knn_classification import score
        If given, use only these data points as neighbors for rescaling.

    test_ind : ndarray, optional (default: None)
        Define data points to be hold out as part of a test set. Can be:

        - None : Rescale all distances
        - ndarray : Hold out points indexed in this array as test set. 

    n_jobs : int, optional, default: 1
        Number of processes for parallel computations.

        - `1`: Don't use multiprocessing.
        - `-1`: Use all CPUs

    Returns
    -------
    D_snn : ndarray
        Secondary distance SNN matrix

    References
    ---------- 
    .. [1] R. Jarvis and E. A. Patrick, “Clustering using a similarity measure
           based on shared near neighbors,” IEEE Transactions on Computers,
           vol. 22, pp. 1025–1034, 1973.

    .. [2] Flexer, A., & Schnitzer, D. (2013). Can Shared Nearest Neighbors
           Reduce Hubness in High-Dimensional Spaces? 2013 IEEE 13th
           International Conference on Data Mining Workshops, 460–467.
           http://doi.org/10.1109/ICDMW.2013.101
    """

# Path: hub_toolbox/io.py
# def load_dexter():
# def check_is_nD_array(arr:np.ndarray, n:int, arr_type=''):
# def check_distance_matrix_shape(D:np.ndarray):
# def check_distance_matrix_shape_fits_vectors(D:np.ndarray, vectors:np.ndarray):
# def check_distance_matrix_shape_fits_labels(D:np.ndarray, classes:np.ndarray):
# def check_vector_matrix_shape_fits_labels(X:np.ndarray, classes:np.ndarray):
# def check_sample_shape_fits(D:np.ndarray, idx:np.ndarray):
# def check_valid_metric_parameter(metric:str):
# def matrix_split(rows, cols, elem_size=8, nr_matrices=4): # pragma: no cover
# def random_sparse_matrix(size, density=0.05):
# def save_csr_matrix(file, matrix):
# def load_csr_matrix(file):
#     def __init__(self, unit='kB'):
#     def _factor(self):
#     def total(self):
#     def used(self):
#     def used_real(self):
#     def shared(self):
#     def buffers(self):
#     def cached(self):
#     def user_free(self):
#     def swap(self):
#     def swap_free(self):
#     def swap_used(self):
#     D = cosine_distance(vectors)
#     S = sparse.rand(size, size, density, 'csr')
# class FreeMemLinux(object): # pragma: no cover


# Path: hub_toolbox/shared_neighbors.py
import ctypes
import numpy as np
from functools import partial
from multiprocessing import cpu_count, Pool, RawArray
from hub_toolbox import io
    from hub_toolbox.hubness import hubness
    from hub_toolbox.knn_classification import score

        If given, use only these data points as neighbors for rescaling.

    test_ind : ndarray, optional (default: None)
        Define data points to be hold out as part of a test set. Can be:

        - None : Rescale all distances
        - ndarray : Hold out points indexed in this array as test set. 

    n_jobs : int, optional, default: 1
        Number of processes for parallel computations.

        - `1`: Don't use multiprocessing.
        - `-1`: Use all CPUs

    Returns
    -------
    D_snn : ndarray
        Secondary distance SNN matrix

    References
    ---------- 
    .. [1] R. Jarvis and E. A. Patrick, “Clustering using a similarity measure
           based on shared near neighbors,” IEEE Transactions on Computers,
           vol. 22, pp. 1025–1034, 1973.

    .. [2] Flexer, A., & Schnitzer, D. (2013). Can Shared Nearest Neighbors
           Reduce Hubness in High-Dimensional Spaces? 2013 IEEE 13th
           International Conference on Data Mining Workshops, 460–467.
           http://doi.org/10.1109/ICDMW.2013.101
    """

    io.check_sample_shape_fits(D, train_ind)