Add deprecated helper

Uses warning to show DeprecationWarning and custom stack trace
This commit is contained in:
ines 2017-11-01 16:32:36 +01:00
parent a7a76ea8c5
commit 39e0586192

View File

@ -11,6 +11,8 @@ import sys
import textwrap
import random
from collections import OrderedDict
import inspect
import warnings
from thinc.neural._classes.model import Model
import functools
@ -501,6 +503,18 @@ def from_disk(path, readers, exclude):
return path
def deprecated(message, filter='always'):
"""Show a deprecation warning.
message (unicode): The message to display.
filter (unicode): Filter value.
"""
stack = inspect.stack()[-1]
with warnings.catch_warnings():
warnings.simplefilter(filter, DeprecationWarning)
warnings.warn_explicit(message, DeprecationWarning, stack[1], stack[2])
def print_table(data, title=None):
"""Print data in table format.