--- theano/compat/__init__.py.orig 2019-01-15 14:13:57.000000000 -0700
+++ theano/compat/__init__.py 2020-02-04 15:18:46.140124315 -0700
@@ -6,15 +6,16 @@ from __future__ import absolute_import,
from six import PY3, b, BytesIO, next
from six.moves import configparser
from six.moves import reload_module as reload
+from collections import OrderedDict
try:
- from collections.abc import (OrderedDict, MutableMapping as DictMixin,
- Callable)
+ from collections.abc import Callable, Iterable, Mapping, ValuesView
+ from collections.abc import MutableMapping as DictMixin
except ImportError:
# this raises an DeprecationWarning on py37 and will become
- # and Exception in py38. Importing from collections.abc
+ # an Exception in py39. Importing from collections.abc
# won't work on py27
- from collections import (OrderedDict, MutableMapping as DictMixin,
- Callable)
+ from collections import Callable, Iterable, Mapping, ValuesView
+ from collections import MutableMapping as DictMixin
__all__ = ['PY3', 'b', 'BytesIO', 'next', 'configparser', 'reload']
@@ -73,8 +74,10 @@ else:
def decode_with(x, encoding):
return x
-__all__ += ['cmp', 'operator_div', 'DictMixin', 'OrderedDict', 'decode',
- 'decode_iter', 'get_unbound_function', 'imap', 'izip', 'ifilter']
+__all__ += ['cmp', 'operator_div',
+ 'DictMixin', 'Iterable', 'Mapping', 'OrderedDict', 'ValuesView',
+ 'decode', 'decode_iter', 'get_unbound_function',
+ 'imap', 'izip', 'ifilter']
class DefaultOrderedDict(OrderedDict):
--- theano/compile/nanguardmode.py.orig 2019-01-15 14:13:57.000000000 -0700
+++ theano/compile/nanguardmode.py 2020-02-04 15:19:44.620193327 -0700
@@ -1,5 +1,4 @@
from __future__ import absolute_import, print_function, division
-import collections
import logging
from six.moves import StringIO
@@ -9,6 +8,7 @@ import theano
from theano import config
import theano.tensor as T
from theano.compile import Mode
+from theano.compat import ValuesView
from .mode import get_mode
try:
@@ -68,7 +68,7 @@ def flatten(l):
A flattened list of objects.
"""
- if isinstance(l, (list, tuple, collections.ValuesView)):
+ if isinstance(l, (list, tuple, ValuesView)):
rval = []
for elem in l:
if isinstance(elem, (list, tuple)):
--- theano/misc/frozendict.py.orig 2019-01-15 14:13:57.000000000 -0700
+++ theano/misc/frozendict.py 2020-02-04 15:20:34.483399527 -0700
@@ -5,10 +5,12 @@ import collections
import operator
import functools
+from theano.compat import Mapping
-class frozendict(collections.Mapping):
+
+class frozendict(Mapping):
"""
- An immutable wrapper around dictionaries that implements the complete :py:class:`collections.Mapping`
+ An immutable wrapper around dictionaries that implements the complete :py:class:`collections.abc.Mapping`
interface. It can be used as a drop-in replacement for dictionaries where immutability and ordering are desired.
"""
--- theano/scalar/basic.py.orig 2019-01-15 14:13:57.000000000 -0700
+++ theano/scalar/basic.py 2020-02-04 15:21:25.436588357 -0700
@@ -22,7 +22,7 @@ import six
from six.moves import xrange
import theano
-from theano.compat import imap, izip
+from theano.compat import imap, izip, Callable
from theano import gof, printing
from theano.gof import (Op, utils, Variable, Constant, Type, Apply,
FunctionGraph)
@@ -33,7 +33,6 @@ from theano.gradient import Disconnected
from theano.gradient import grad_undefined
from theano.printing import pprint
-import collections
builtin_bool = bool
builtin_complex = complex
@@ -1028,7 +1027,7 @@ class ScalarOp(Op):
def __init__(self, output_types_preference=None, name=None):
self.name = name
if output_types_preference is not None:
- if not isinstance(output_types_preference, collections.Callable):
+ if not isinstance(output_types_preference, Callable):
raise TypeError(
"Expected a callable for the 'output_types_preference' argument to %s. (got: %s)" %
(self.__class__, output_types_preference))
--- theano/tensor/nnet/abstract_conv.py.orig 2019-01-15 14:13:57.000000000 -0700
+++ theano/tensor/nnet/abstract_conv.py 2020-02-04 15:22:04.363968631 -0700
@@ -6,7 +6,10 @@ from __future__ import absolute_import,
import logging
from six import reraise, integer_types
import sys
-from fractions import gcd
+try:
+ from math import gcd
+except ImportError:
+ from fractions import gcd
import theano
--- theano/tensor/subtensor.py.orig 2019-08-05 13:07:26.579871929 -0600
+++ theano/tensor/subtensor.py 2020-02-04 15:22:49.131255955 -0700
@@ -1,7 +1,6 @@
from __future__ import absolute_import, print_function, division
import sys
from textwrap import dedent
-import collections
import warnings
import logging
@@ -22,6 +21,7 @@ from theano.tensor.basic import (addbroa
from theano.tensor.elemwise import DimShuffle
from theano.tensor.type_other import NoneConst, SliceType, NoneTypeT, make_slice
from theano import config
+from theano.compat import Iterable
from .inc_code import inc_code
@@ -2154,7 +2154,7 @@ def check_and_reject_bool(args_el):
pass
if (not isinstance(args_el, theano.tensor.Variable) and
- isinstance(args_el, collections.Iterable)):
+ isinstance(args_el, Iterable)):
for el in args_el:
check_and_reject_bool(el)