# Path: hub_toolbox/utils.py
# class SynchronizedCounter(object):
#     """ A multiprocessing-safe counter for progress information. """
#     def __init__(self, init:int=-1):
#         self.val = Value('i', init)
# 
#     def increment_and_get_value(self, n=1) -> int:
#         """ Obtain a lock before incrementing, since += isn't atomic. """
#         with self.val.get_lock():
#             self.val.value += n
#             return self.val.value
# 
#     @property
#     def value(self) -> int:
#         return self.val.value
# 
# 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 os
import warnings
import numpy as np
import pandas as pd
    import nmslib
    import falconn
from functools import partial
from multiprocessing import cpu_count, RawArray, Pool
from scipy import sparse
from scipy.sparse.base import issparse
from scipy.stats import norm
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.model_selection import StratifiedShuffleSplit, ShuffleSplit
from sklearn.metrics import euclidean_distances
from sklearn.metrics.pairwise import cosine_distances
from sklearn.neighbors.classification import KNeighborsClassifier
from sklearn.utils import check_random_state, check_array
from sklearn.utils.extmath import row_norms, stable_cumsum
from sklearn.utils.validation import check_is_fitted
from hub_toolbox.utils import SynchronizedCounter
from hub_toolbox.htlogging import ConsoleLogging
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
This file is part of the HUB TOOLBOX available at
https://github.com/OFAI/hub-toolbox-python3/
Licensed under the terms of the GNU GPLv3.

(c) 2018, Roman Feldbauer
Austrian Research Institute for Artificial Intelligence (OFAI)
Contact: <roman.feldbauer@ofai.at>
"""

try:
    nms_avail = True
except ImportError:
    nms_avail = False
try:
    falconn_avail = True
except ImportError:
    falconn_avail = False

__all__ = ['ApproximateHubnessReduction']

VALID_HR = ["MP", "MPG", "LS", "NICDM", "DSL", None]
VALID_SAMPLE = ['random', 'kmeans++', 'lsh', 'hnsw', None]
VALID_METRICS = ['sqeuclidean', 'cosine', 'precomputed']
VALID_PREDICTORS = ['knn']

# Path: hub_toolbox/utils.py
# class SynchronizedCounter(object):
#     """ A multiprocessing-safe counter for progress information. """
#     def __init__(self, init:int=-1):
#         self.val = Value('i', init)
# 
#     def increment_and_get_value(self, n=1) -> int:
#         """ Obtain a lock before incrementing, since += isn't atomic. """
#         with self.val.get_lock():
#             self.val.value += n
#             return self.val.value
# 
#     @property
#     def value(self) -> int:
#         return self.val.value
# 
# 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/approximate.py
import ctypes
import os
import warnings
import numpy as np
import pandas as pd
    import nmslib
    import falconn
from functools import partial
from multiprocessing import cpu_count, RawArray, Pool
from scipy import sparse
from scipy.sparse.base import issparse
from scipy.stats import norm
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.model_selection import StratifiedShuffleSplit, ShuffleSplit
from sklearn.metrics import euclidean_distances
from sklearn.metrics.pairwise import cosine_distances
from sklearn.neighbors.classification import KNeighborsClassifier
from sklearn.utils import check_random_state, check_array
from sklearn.utils.extmath import row_norms, stable_cumsum
from sklearn.utils.validation import check_is_fitted
from hub_toolbox.utils import SynchronizedCounter
from hub_toolbox.htlogging import ConsoleLogging

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
This file is part of the HUB TOOLBOX available at
https://github.com/OFAI/hub-toolbox-python3/
Licensed under the terms of the GNU GPLv3.

(c) 2018, Roman Feldbauer
Austrian Research Institute for Artificial Intelligence (OFAI)
Contact: <roman.feldbauer@ofai.at>
"""

try:
    nms_avail = True
except ImportError:
    nms_avail = False
try:
    falconn_avail = True
except ImportError:
    falconn_avail = False

__all__ = ['ApproximateHubnessReduction']

VALID_HR = ["MP", "MPG", "LS", "NICDM", "DSL", None]
VALID_SAMPLE = ['random', 'kmeans++', 'lsh', 'hnsw', None]
VALID_METRICS = ['sqeuclidean', 'cosine', 'precomputed']
VALID_PREDICTORS = ['knn']

log = ConsoleLogging()