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

pep8

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