提交 af1314a0 authored 作者: David Warde-Farley's avatar David Warde-Farley 提交者: Arnaud Bergeron

Fix get_unbound_function that had been modified in six.

上级 cbcc42e4
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
""" """
# Python 3.x compatibility # Python 3.x compatibility
from theano.compat.six import PY3, b, BytesIO, next, get_unbound_function from theano.compat.six import PY3, b, BytesIO, next
from theano.compat.six.moves import configparser from theano.compat.six.moves import configparser
from theano.compat.six.moves import reload_module as reload from theano.compat.six.moves import reload_module as reload
__all__ = ['PY3', 'b', 'BytesIO', 'next', 'get_unbound_function', __all__ = ['PY3', 'b', 'BytesIO', 'next', 'configparser', 'reload']
'configparser', 'reload']
if PY3: if PY3:
from operator import truediv as operator_div from operator import truediv as operator_div
...@@ -25,6 +24,16 @@ if PY3: ...@@ -25,6 +24,16 @@ if PY3:
"""Return -1 if x < y, 0 if x == y, 1 if x > y.""" """Return -1 if x < y, 0 if x == y, 1 if x > y."""
return (x > y) - (x < y) return (x > y) - (x < y)
def get_unbound_function(unbound):
# Op.make_thunk isn't bound, so don't have a __func__ attr.
# But bound method, have a __func__ method that point to the
# not bound method. That is what we want.
if hasattr(unbound, '__func__'):
return unbound.__func__
return unbound
from functools import partial from functools import partial
from collections import defaultdict, deque from collections import defaultdict, deque
from sys import maxsize from sys import maxsize
...@@ -38,7 +47,7 @@ if PY3: ...@@ -38,7 +47,7 @@ if PY3:
for x in itr: for x in itr:
yield x.decode() yield x.decode()
else: else:
from theano.compat.six import get_unbound_function
from operator import div as operator_div from operator import div as operator_div
def exc_message(e): def exc_message(e):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论