# Path: mlens/utils/exceptions.py
# class NotFittedError(ValueError, AttributeError):
# 
#     """Error class for an ensemble or estimator that is not fitted yet
# 
#     Raised when some method has been called that expects the instance to be
#     fitted.
#     """
# 
# class LayerSpecificationWarning(UserWarning):
# 
#     """Warning class if layer has been specified in a dubious form.
# 
#     This warning is raised when the input does not look like expected, but
#     is not fatal and a best guess of how to fix it will be made.
#     """
# 
# class LayerSpecificationError(TypeError, ValueError):
# 
#     """Error class for incorrectly specified layers."""
# 
# class ParallelProcessingError(AttributeError, RuntimeError):
# 
#     """Error class for fatal errors related to :class:`ParallelProcessing`.
# 
#     Can be subclassed for more specific error classes.
#     """
# 
# class ParallelProcessingWarning(UserWarning):
# 
#     """Warnings related to methods on :class:`ParallelProcessing`.
# 
#     Can be subclassed for more specific warning classes.
#     """


import warnings
from .exceptions import (NotFittedError, LayerSpecificationWarning,
                         LayerSpecificationError, ParallelProcessingError,
                         ParallelProcessingWarning)
        if not isinstance(estimators, dict):
            msg = ("Unexpected format of 'estimators'. Needs to be "
                   "'dict' when preprocessing is 'dict'. Got %s.")
            raise LayerSpecificationError(msg % type(estimators))

        # Check that keys overlap
        prep_check = [key in preprocessing for key in estimators]
        est_check = [key in estimators for key in preprocessing]

        if not all(est_check):
            msg = ("Too few estimator cases to match preprocessing cases:\n"
                   "estimator cases:     %r\npreprocessing cases: %r")
            raise LayerSpecificationError(msg % (list(estimators),
                                                 list(preprocessing)))
        if not all(prep_check):
            msg = ("Too few preprocessing cases to match estimators cases:\n"
                   "preprocessing cases: %r\nestimator cases:     %r")
            raise LayerSpecificationError(msg % (list(preprocessing),
                                                 list(estimators)))


def check_initialized(inst):
    """Check if a ParallelProcessing instance is initialized properly."""
    if not inst.__initialized__:
        msg = "ParallelProcessing is not initialized. Call " \
              "'initialize' before calling 'fit'."
        raise ParallelProcessingError(msg)

    if getattr(inst, '__fitted__', None):
        if inst.layers.raise_on_exception:

# Path: mlens/utils/exceptions.py
# class NotFittedError(ValueError, AttributeError):
# 
#     """Error class for an ensemble or estimator that is not fitted yet
# 
#     Raised when some method has been called that expects the instance to be
#     fitted.
#     """
# 
# class LayerSpecificationWarning(UserWarning):
# 
#     """Warning class if layer has been specified in a dubious form.
# 
#     This warning is raised when the input does not look like expected, but
#     is not fatal and a best guess of how to fix it will be made.
#     """
# 
# class LayerSpecificationError(TypeError, ValueError):
# 
#     """Error class for incorrectly specified layers."""
# 
# class ParallelProcessingError(AttributeError, RuntimeError):
# 
#     """Error class for fatal errors related to :class:`ParallelProcessing`.
# 
#     Can be subclassed for more specific error classes.
#     """
# 
# class ParallelProcessingWarning(UserWarning):
# 
#     """Warnings related to methods on :class:`ParallelProcessing`.
# 
#     Can be subclassed for more specific warning classes.
#     """


# Path: mlens/utils/checks.py
import warnings
from .exceptions import (NotFittedError, LayerSpecificationWarning,
                         LayerSpecificationError, ParallelProcessingError,
                         ParallelProcessingWarning)

        if not isinstance(estimators, dict):
            msg = ("Unexpected format of 'estimators'. Needs to be "
                   "'dict' when preprocessing is 'dict'. Got %s.")
            raise LayerSpecificationError(msg % type(estimators))

        # Check that keys overlap
        prep_check = [key in preprocessing for key in estimators]
        est_check = [key in estimators for key in preprocessing]

        if not all(est_check):
            msg = ("Too few estimator cases to match preprocessing cases:\n"
                   "estimator cases:     %r\npreprocessing cases: %r")
            raise LayerSpecificationError(msg % (list(estimators),
                                                 list(preprocessing)))
        if not all(prep_check):
            msg = ("Too few preprocessing cases to match estimators cases:\n"
                   "preprocessing cases: %r\nestimator cases:     %r")
            raise LayerSpecificationError(msg % (list(preprocessing),
                                                 list(estimators)))


def check_initialized(inst):
    """Check if a ParallelProcessing instance is initialized properly."""
    if not inst.__initialized__:
        msg = "ParallelProcessing is not initialized. Call " \
              "'initialize' before calling 'fit'."
        raise ParallelProcessingError(msg)

    if getattr(inst, '__fitted__', None):
        if inst.layers.raise_on_exception:

            raise ParallelProcessingError("This instance is already "