hub/venv/lib/python3.7/site-packages/scipy/_lib/deprecation.py

25 lines
658 B
Python
Raw Normal View History

import functools
import warnings
__all__ = ["_deprecated"]
def _deprecated(msg, stacklevel=2):
"""Deprecate a function by emitting a warning on use."""
def wrap(fun):
if isinstance(fun, type):
warnings.warn(
"Trying to deprecate class {!r}".format(fun),
category=RuntimeWarning, stacklevel=2)
return fun
@functools.wraps(fun)
def call(*args, **kwargs):
warnings.warn(msg, category=DeprecationWarning,
stacklevel=stacklevel)
return fun(*args, **kwargs)
call.__doc__ = msg
return call
return wrap