import functools
import warnings


def deprecate(msg, _type=DeprecationWarning):
    """
    Decorator that generates a deprecation message

    Parameters
    ----------
    - msg: string message
    - type: DeprecationWarning by default
    """
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            warnings.warn(msg, _type, stacklevel=2)
            return func(*args, **kwargs)
        return wrapper
    return decorator