# Path: hub_toolbox/io.py
# def check_vector_matrix_shape_fits_labels(X:np.ndarray, classes:np.ndarray):
#     """ Check the number of points in vector matrix equal number of labels."""
#     check_is_nD_array(X, 2, "Data vectors")
#     check_is_nD_array(classes, 1, "Class label")
#     if classes.size != X.shape[0]:
#         raise TypeError("Number of class labels does not match number of "
#                         "points. Labels: {}, points: {}."
#                         .format(classes.size, X.shape[0]))
# 
# 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()


import ctypes
import numpy as np
from multiprocessing import Pool, cpu_count, RawArray
from scipy.spatial.distance import cdist, pdist, squareform
    from sklearn.model_selection import StratifiedShuffleSplit
    from sklearn.cross_validation import StratifiedShuffleSplit
from sklearn.metrics.pairwise import pairwise_distances
from hub_toolbox.io import check_vector_matrix_shape_fits_labels
from hub_toolbox.htlogging import ConsoleLogging
                same points are chosen.
        - 'b': Stratified sampling, for each point it is chosen independently,
                to which other points distances are calculated.
                NOTE: currently not implemented.

    random_state : int or RandomState
        Pseudo-random number generator state used for random sampling.

    Returns
    -------
    D : ndarray
        The ``n x s`` distance matrix, where ``n`` is the dataset size and
        ``s`` is the sample size.

    y_sample : ndarray
        The index array that determines, which column in `D` corresponds
        to which data point.
        
        NOTE: The size of `y_sample` may be slightly higher than defined by
        `sample_size` in order to meet stratification requirements!
        Thus, please always check the size in the downstream workflow.

    Notes
    -----
    Only calculate distances to a fixed number/fraction of all ``n`` points.
    These ``s`` points are sampled according to the chosen strategy (see above).
    In other words, calculate the distance from all points to each point
    in the sample to obtain a ``n x s`` distance matrix.
    
    """

# Path: hub_toolbox/io.py
# def check_vector_matrix_shape_fits_labels(X:np.ndarray, classes:np.ndarray):
#     """ Check the number of points in vector matrix equal number of labels."""
#     check_is_nD_array(X, 2, "Data vectors")
#     check_is_nD_array(classes, 1, "Class label")
#     if classes.size != X.shape[0]:
#         raise TypeError("Number of class labels does not match number of "
#                         "points. Labels: {}, points: {}."
#                         .format(classes.size, X.shape[0]))
# 
# 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/distances.py
import ctypes
import numpy as np
from multiprocessing import Pool, cpu_count, RawArray
from scipy.spatial.distance import cdist, pdist, squareform
    from sklearn.model_selection import StratifiedShuffleSplit
    from sklearn.cross_validation import StratifiedShuffleSplit
from sklearn.metrics.pairwise import pairwise_distances
from hub_toolbox.io import check_vector_matrix_shape_fits_labels
from hub_toolbox.htlogging import ConsoleLogging

                same points are chosen.
        - 'b': Stratified sampling, for each point it is chosen independently,
                to which other points distances are calculated.
                NOTE: currently not implemented.

    random_state : int or RandomState
        Pseudo-random number generator state used for random sampling.

    Returns
    -------
    D : ndarray
        The ``n x s`` distance matrix, where ``n`` is the dataset size and
        ``s`` is the sample size.

    y_sample : ndarray
        The index array that determines, which column in `D` corresponds
        to which data point.
        
        NOTE: The size of `y_sample` may be slightly higher than defined by
        `sample_size` in order to meet stratification requirements!
        Thus, please always check the size in the downstream workflow.

    Notes
    -----
    Only calculate distances to a fixed number/fraction of all ``n`` points.
    These ``s`` points are sampled according to the chosen strategy (see above).
    In other words, calculate the distance from all points to each point
    in the sample to obtain a ``n x s`` distance matrix.
    
    """

    check_vector_matrix_shape_fits_labels(X, y)