提交 8178abbd authored 作者: Frederic's avatar Frederic

pep8

上级 6469c740
"""Symbolic Op for raising an exception."""
__authors__ = "James Bergstra"
__authors__ = "James Bergstra"
__copyright__ = "(c) 2011, Universite de Montreal"
__license__ = "3-clause BSD License"
__contact__ = "theano-dev <theano-dev@googlegroups.com>"
__license__ = "3-clause BSD License"
__contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__ = "restructuredtext en"
from theano import gof
class Raise(gof.Op):
"""Op whose perform() raises an exception.
"""
......@@ -18,19 +19,22 @@ class Raise(gof.Op):
"""
self.msg = msg
self.exc = exc
def __eq__(self, other):
# Note: the msg does not technically have to be in the hash and eq
# because it doesn't affect the return value.
return (type(self) == type(other)
and self.msg == other.msg
and self.exc == other.exc)
def __hash__(self):
return hash((type(self), self.msg, self.exc))
def __str__(self):
return "Raise{%s(%s)}"%(self.exc, self.msg)
return "Raise{%s(%s)}" % (self.exc, self.msg)
def make_node(self, x):
return gof.Apply(self, [x], [x.type()])
def perform(self, node, inputs, out_storage):
raise self.exc(self.msg)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论