提交 aba91dac authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Make deprecation warnings print only once

上级 6d33775d
...@@ -23,10 +23,18 @@ import mode as get_mode ...@@ -23,10 +23,18 @@ import mode as get_mode
#parts of theano do "from module import *" #parts of theano do "from module import *"
#So rather than printing out a warning if you import from this module, we #So rather than printing out a warning if you import from this module, we
#must stick a warning inside all of the components #must stick a warning inside all of the components
def deprecation_warning(): def deprecation_warning():
warnings.warn("theano modules are deprecated and will be removed in release 0.7", # Make sure the warning is displayed only once.
stacklevel = 3) if deprecation_warning.already_displayed:
return
warnings.warn(
"theano modules are deprecated and will be removed in release 0.7",
stacklevel=3)
deprecation_warning.already_displayed = True
deprecation_warning.already_displayed = False
def name_join(*args): def name_join(*args):
......
...@@ -11,8 +11,20 @@ from theano.gof import Container ...@@ -11,8 +11,20 @@ from theano.gof import Container
from theano.tensor import raw_random from theano.tensor import raw_random
import warnings import warnings
def deprecation_warning(): def deprecation_warning():
warnings.warn("RandomStreams is deprecated and will be removed in release 0.7. Use shared_randomstreams.RandomStreams or MRG_RandomStreams instead.",stacklevel = 3) # Make sure the warning is displayed only once.
if deprecation_warning.already_displayed:
return
warnings.warn((
"RandomStreams is deprecated and will be removed in release 0.7. "
"Use shared_randomstreams.RandomStreams or "
"MRG_RandomStreams instead."),
stacklevel=3)
deprecation_warning.already_displayed = True
deprecation_warning.already_displayed = False
class RandomStreamsInstance(object): class RandomStreamsInstance(object):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论