# 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/htlogging.py
# class ConsoleLogging(Logging):
#     """Convenience functions for time-stamped logging to the console"""
# 
#     def message(self, *objs, flush=True):
#         """Log normal program function"""
#         print(self._current_time, 'INFO:', *objs)
#         if flush:
#             sys.stdout.flush()
# 
#     def warning(self, *objs, flush=True):
#         """Log warning (program can still continue)"""
#         print(self._current_time, 'WARNING:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()
# 
#     def error(self, *objs, flush=True):
#         """Log error (program fails)"""
#         print(self._current_time, 'ERROR:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()


from functools import partial
from itertools import filterfalse
from scipy.special import gammainc  # @UnresolvedImport
from scipy.stats import norm
from scipy.sparse import lil_matrix, csr_matrix, issparse
from multiprocessing import Pool, cpu_count, current_process
from multiprocessing.sharedctypes import Array
from hub_toolbox import io
from hub_toolbox.htlogging import ConsoleLogging
import ctypes
import numpy as np
        are the dataset and sample size, respectively.

    idx : ndarray
        The index array that determines, to which data points the columns in
        `D` correspond.

    metric : {'distance', 'similarity'}, optional (default: 'distance')
        Define, whether matrix `D` is a distance or similarity matrix.

    test_sed_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.

    verbose : int, optional (default: 0)
        Increasing level of output (progress report).

    Returns
    -------
    D_mp : ndarray
        Secondary distance MP empiric matrix.

    References
    ----------
    .. [1] Schnitzer, D., Flexer, A., Schedl, M., & Widmer, G. (2012).
           Local and global scaling reduce hubs in space. The Journal of Machine
           Learning Research, 13(1), 2871–2902.
    """
    # Initialization and checking input

# 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/htlogging.py
# class ConsoleLogging(Logging):
#     """Convenience functions for time-stamped logging to the console"""
# 
#     def message(self, *objs, flush=True):
#         """Log normal program function"""
#         print(self._current_time, 'INFO:', *objs)
#         if flush:
#             sys.stdout.flush()
# 
#     def warning(self, *objs, flush=True):
#         """Log warning (program can still continue)"""
#         print(self._current_time, 'WARNING:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()
# 
#     def error(self, *objs, flush=True):
#         """Log error (program fails)"""
#         print(self._current_time, 'ERROR:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()


# Path: hub_toolbox/global_scaling.py
from functools import partial
from itertools import filterfalse
from scipy.special import gammainc  # @UnresolvedImport
from scipy.stats import norm
from scipy.sparse import lil_matrix, csr_matrix, issparse
from multiprocessing import Pool, cpu_count, current_process
from multiprocessing.sharedctypes import Array
from hub_toolbox import io
from hub_toolbox.htlogging import ConsoleLogging
import ctypes
import numpy as np

        are the dataset and sample size, respectively.

    idx : ndarray
        The index array that determines, to which data points the columns in
        `D` correspond.

    metric : {'distance', 'similarity'}, optional (default: 'distance')
        Define, whether matrix `D` is a distance or similarity matrix.

    test_sed_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.

    verbose : int, optional (default: 0)
        Increasing level of output (progress report).

    Returns
    -------
    D_mp : ndarray
        Secondary distance MP empiric matrix.

    References
    ----------
    .. [1] Schnitzer, D., Flexer, A., Schedl, M., & Widmer, G. (2012).
           Local and global scaling reduce hubs in space. The Journal of Machine
           Learning Research, 13(1), 2871–2902.
    """
    # Initialization and checking input

    log = ConsoleLogging()