mirror of https://github.com/explosion/spaCy.git
Add deprecated helper
Uses warning to show DeprecationWarning and custom stack trace
This commit is contained in:
parent
a7a76ea8c5
commit
39e0586192
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue