# Path: mlens/utils/utils.py
# def pickle_save(obj, name):
#     """Utility function for pickling an object"""
#     with open(pickled(name), 'wb') as f:
#         pickle.dump(obj, f)
# 
# def pickle_load(name):
#     """Utility function for loading pickled object"""
#     with open(pickled(name), 'rb') as f:
#         return pickle.load(f)
# 
# def load(file, enforce_filetype=True):
#     """Utility exception handler for loading file"""
#     s, lim = get_ivals()
#     if enforce_filetype:
#         file = pickled(file)
#     try:
#         return pickle_load(file)
#     except (EOFError, OSError, IOError) as exc:
#         msg = str(exc)
#         warnings.warn(
#             "Could not load transformer at %s. Will check every %.1f seconds "
#             "for %i seconds before aborting. " % (file, s, lim),
#             ParallelProcessingWarning)
# 
#         ts = time()
#         while not os.path.exists(file):
#             sleep(s)
#             if time() - ts > lim:
#                 raise ParallelProcessingError(
#                     "Could not load transformer at %s\nDetails:\n%r" %
#                     (dir, msg))
# 
#         return pickle_load(file)
# 
# Path: mlens/utils/exceptions.py
# class MetricWarning(UserWarning):
# 
#     """Warning to notify that scoring do not behave as expected.
# 
#     Raised if scoring fails or if aggregating scores fails.
#     """
# 
# class ParameterChangeWarning(UserWarning):
# 
#     """Warning for different params in blueprint estimator and fitted copy.
# 
#     .. versionadded:: 0.2.2
#     """


import os
import warnings
import numpy as np
from scipy.sparse import issparse
from ..utils import pickle_load, pickle_save, load as _load
from ..utils.exceptions import MetricWarning, ParameterChangeWarning
"""ML-Ensemble

:author: Sebastian Flennerhag
:license: MIT
:copyright: 2017-2018

Functions for base computations
"""
from __future__ import division




def load(path, name, raise_on_exception=True):
    """Utility for loading from cache"""
    if isinstance(path, str):
        f = os.path.join(path, name)

# Path: mlens/utils/utils.py
# def pickle_save(obj, name):
#     """Utility function for pickling an object"""
#     with open(pickled(name), 'wb') as f:
#         pickle.dump(obj, f)
# 
# def pickle_load(name):
#     """Utility function for loading pickled object"""
#     with open(pickled(name), 'rb') as f:
#         return pickle.load(f)
# 
# def load(file, enforce_filetype=True):
#     """Utility exception handler for loading file"""
#     s, lim = get_ivals()
#     if enforce_filetype:
#         file = pickled(file)
#     try:
#         return pickle_load(file)
#     except (EOFError, OSError, IOError) as exc:
#         msg = str(exc)
#         warnings.warn(
#             "Could not load transformer at %s. Will check every %.1f seconds "
#             "for %i seconds before aborting. " % (file, s, lim),
#             ParallelProcessingWarning)
# 
#         ts = time()
#         while not os.path.exists(file):
#             sleep(s)
#             if time() - ts > lim:
#                 raise ParallelProcessingError(
#                     "Could not load transformer at %s\nDetails:\n%r" %
#                     (dir, msg))
# 
#         return pickle_load(file)
# 
# Path: mlens/utils/exceptions.py
# class MetricWarning(UserWarning):
# 
#     """Warning to notify that scoring do not behave as expected.
# 
#     Raised if scoring fails or if aggregating scores fails.
#     """
# 
# class ParameterChangeWarning(UserWarning):
# 
#     """Warning for different params in blueprint estimator and fitted copy.
# 
#     .. versionadded:: 0.2.2
#     """


# Path: mlens/parallel/_base_functions.py
import os
import warnings
import numpy as np
from scipy.sparse import issparse
from ..utils import pickle_load, pickle_save, load as _load
from ..utils.exceptions import MetricWarning, ParameterChangeWarning

"""ML-Ensemble

:author: Sebastian Flennerhag
:license: MIT
:copyright: 2017-2018

Functions for base computations
"""
from __future__ import division




def load(path, name, raise_on_exception=True):
    """Utility for loading from cache"""
    if isinstance(path, str):
        f = os.path.join(path, name)

        obj = _load(f, raise_on_exception)