LSR/env/lib/python3.6/site-packages/scipy/_lib/deprecation.py

25 lines
658 B
Python
Raw Normal View History

2020-06-04 17:24:47 +02:00
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