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

Remove >= 2.6-compatible stuff from compat.

Also remove unused import of Callable.
上级 0162c1d9
...@@ -55,11 +55,6 @@ else: ...@@ -55,11 +55,6 @@ else:
return e[0] return e[0]
cmp = cmp cmp = cmp
from functools import partial
from collections import defaultdict, deque
from itertools import combinations, product
from sys import maxsize
# Older Python 2.x compatibility # Older Python 2.x compatibility
from theano.compat.python2x import DictMixin, OrderedDict from theano.compat.python2x import DictMixin, OrderedDict
...@@ -70,9 +65,8 @@ else: ...@@ -70,9 +65,8 @@ else:
def decode_iter(x): def decode_iter(x):
return x return x
__all__ += ['cmp', 'operator_div', 'partial', 'defaultdict', 'deque', __all__ += ['cmp', 'operator_div', 'DictMixin', 'OrderedDict', 'decode',
'combinations', 'product', 'maxsize', 'DictMixin', 'decode_iter']
'OrderedDict', 'decode', 'decode_iter']
class DefaultOrderedDict(OrderedDict): class DefaultOrderedDict(OrderedDict):
......
...@@ -367,7 +367,6 @@ else: ...@@ -367,7 +367,6 @@ else:
from UserDict import DictMixin from UserDict import DictMixin
except ImportError: except ImportError:
from collections import MutableMapping as DictMixin from collections import MutableMapping as DictMixin
from collections import OrderedDict, Callable, Counter from collections import OrderedDict, Counter
Callable = Callable
__all__ = ['DictMixin', 'OrderedDict', 'Counter'] __all__ = ['DictMixin', 'OrderedDict', 'Counter']
...@@ -9,14 +9,14 @@ import copy ...@@ -9,14 +9,14 @@ import copy
import sys import sys
import copy_reg import copy_reg
import gc import gc
from itertools import izip
import logging import logging
from itertools import izip, product as itertools_product
import numpy import numpy
import theano import theano
from theano import gof from theano import gof
from theano.compat import get_unbound_function, product as itertools_product from theano.compat import get_unbound_function
from theano.compat.six.moves import StringIO, xrange from theano.compat.six.moves import StringIO, xrange
from theano.gof import (FunctionGraph, graph, utils, link, from theano.gof import (FunctionGraph, graph, utils, link,
ops_with_inner_function) ops_with_inner_function)
......
...@@ -12,7 +12,8 @@ import numpy ...@@ -12,7 +12,8 @@ import numpy
import theano import theano
from theano import gof from theano import gof
from theano.compat import partial from functools import partial
from theano.compat.six import string_types
from theano.compat.six.moves import xrange from theano.compat.six.moves import xrange
import theano.compile.mode import theano.compile.mode
from theano.compile.io import ( from theano.compile.io import (
......
...@@ -20,7 +20,7 @@ import copy ...@@ -20,7 +20,7 @@ import copy
import os import os
import sys import sys
import time import time
from theano.compat import defaultdict from collections import defaultdict
import numpy import numpy
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
Classes and functions for validating graphs that contain view Classes and functions for validating graphs that contain view
and inplace operations. and inplace operations.
""" """
from collections import deque
import theano import theano
from . import toolbox from . import toolbox
from . import graph from . import graph
from theano.compat import deque, OrderedDict from theano.compat import OrderedDict
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
from .fg import InconsistencyError from .fg import InconsistencyError
......
...@@ -9,7 +9,7 @@ from __future__ import print_function ...@@ -9,7 +9,7 @@ from __future__ import print_function
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
from collections import deque
from copy import copy from copy import copy
from itertools import count from itertools import count
...@@ -17,7 +17,6 @@ from itertools import count ...@@ -17,7 +17,6 @@ from itertools import count
import theano import theano
import warnings import warnings
from theano.gof import utils from theano.gof import utils
from theano.compat import deque
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
# Lazy imports to avoid circular dependencies. # Lazy imports to avoid circular dependencies.
......
...@@ -4,6 +4,7 @@ amount of useful generic optimization tools. ...@@ -4,6 +4,7 @@ amount of useful generic optimization tools.
""" """
from __future__ import print_function from __future__ import print_function
from collections import deque
import copy import copy
import logging import logging
import pdb import pdb
...@@ -19,7 +20,6 @@ from theano import config ...@@ -19,7 +20,6 @@ from theano import config
from theano.compat.six.moves import reduce from theano.compat.six.moves import reduce
from theano.gof import graph, op, utils, unify, toolbox from theano.gof import graph, op, utils, unify, toolbox
from theano.gof.fg import InconsistencyError from theano.gof.fg import InconsistencyError
from theano.compat import deque
from . import destroyhandler as dh from . import destroyhandler as dh
......
from collections import defaultdict
from theano.gof.graph import list_of_nodes from theano.gof.graph import list_of_nodes
from theano.compat import cmp, defaultdict from theano.compat import cmp
# {{{ http://code.activestate.com/recipes/578231/ (r1) # {{{ http://code.activestate.com/recipes/578231/ (r1)
# Copyright (c) Oren Tirosh 2012 # Copyright (c) Oren Tirosh 2012
......
from __future__ import print_function from __future__ import print_function
from functools import partial
import sys import sys
import time import time
import theano import theano
from theano import config from theano import config
from theano.compat import partial, OrderedDict from theano.compat import OrderedDict
from theano.gof import graph from theano.gof import graph
......
...@@ -10,7 +10,7 @@ if there exists an assignment to all unification variables such that ...@@ -10,7 +10,7 @@ if there exists an assignment to all unification variables such that
from __future__ import print_function from __future__ import print_function
from copy import copy from copy import copy
from theano.compat import partial from functools import partial
from theano.gof.utils import * from theano.gof.utils import *
......
...@@ -4,6 +4,7 @@ A VM is not actually different from a Linker, we just decided ...@@ -4,6 +4,7 @@ A VM is not actually different from a Linker, we just decided
VM was a better name at some point. VM was a better name at some point.
""" """
from . import link from . import link
from collections import defaultdict
import logging import logging
import os import os
import sys import sys
...@@ -15,7 +16,6 @@ from theano.configparser import (config, AddConfigVar, ...@@ -15,7 +16,6 @@ from theano.configparser import (config, AddConfigVar,
import theano.gof.cmodule import theano.gof.cmodule
from theano.compat import defaultdict
from theano.compat.six.moves import xrange from theano.compat.six.moves import xrange
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
......
...@@ -26,7 +26,7 @@ from theano.compat import PY3 ...@@ -26,7 +26,7 @@ from theano.compat import PY3
from theano import gof, printing from theano import gof, printing
from theano.gof import (Op, utils, Variable, Constant, Type, Apply, from theano.gof import (Op, utils, Variable, Constant, Type, Apply,
FunctionGraph) FunctionGraph)
from theano.compat import partial from functools import partial
from theano.configparser import config from theano.configparser import config
from theano.gradient import DisconnectedType from theano.gradient import DisconnectedType
......
...@@ -59,13 +59,14 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>" ...@@ -59,13 +59,14 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import logging import logging
import copy import copy
from sys import maxsize
import numpy import numpy
import theano import theano
from theano import tensor from theano import tensor
from theano.tensor import opt, get_scalar_constant_value from theano.tensor import opt, get_scalar_constant_value
from theano import gof from theano import gof
from theano.compat import maxsize, OrderedDict from theano.compat import OrderedDict
from theano.gof.opt import Optimizer from theano.gof.opt import Optimizer
from theano.gof import toolbox, DestroyHandler, InconsistencyError from theano.gof import toolbox, DestroyHandler, InconsistencyError
from theano.compile import optdb from theano.compile import optdb
......
from itertools import product
import time import time
import unittest import unittest
...@@ -16,7 +17,6 @@ from theano import tensor ...@@ -16,7 +17,6 @@ from theano import tensor
from theano import sparse from theano import sparse
from theano import compile, config, gof from theano import compile, config, gof
from theano.sparse import enable_sparse from theano.sparse import enable_sparse
from theano.compat import product
from theano.tensor.basic import _allclose from theano.tensor.basic import _allclose
if not enable_sparse: if not enable_sparse:
......
...@@ -20,7 +20,8 @@ from theano.tensor.var import (AsTensorError, TensorVariable, ...@@ -20,7 +20,8 @@ from theano.tensor.var import (AsTensorError, TensorVariable,
from theano.tensor.type import TensorType, values_eq_approx_always_true from theano.tensor.type import TensorType, values_eq_approx_always_true
from theano.tensor.type_other import NoneConst from theano.tensor.type_other import NoneConst
from theano import scalar as scal from theano import scalar as scal
from theano.compat import partial from functools import partial
from theano.compat.six import integer_types
from theano.gof.utils import hashtype from theano.gof.utils import hashtype
from theano import compile, printing from theano import compile, printing
from theano.printing import pprint, min_informative_str from theano.printing import pprint, min_informative_str
......
...@@ -24,7 +24,6 @@ from theano import gof ...@@ -24,7 +24,6 @@ from theano import gof
from theano.compat.six.moves import reduce from theano.compat.six.moves import reduce
from theano.gof import opt, InconsistencyError, TopoOptimizer, graph from theano.gof import opt, InconsistencyError, TopoOptimizer, graph
from theano.gof import Variable, Constant from theano.gof import Variable, Constant
from theano.compat import maxsize
from theano.gof.utils import MethodNotDefined from theano.gof.utils import MethodNotDefined
from theano.gradient import DisconnectedType from theano.gradient import DisconnectedType
from theano.configparser import config from theano.configparser import config
...@@ -2082,7 +2081,7 @@ def local_useless_subtensor(node): ...@@ -2082,7 +2081,7 @@ def local_useless_subtensor(node):
length_pos = shape_of[node.inputs[0]][pos] length_pos = shape_of[node.inputs[0]][pos]
if isinstance(idx.stop, (int, numpy.integer)): if isinstance(idx.stop, (int, numpy.integer)):
length_pos_data = maxsize length_pos_data = sys.maxsize
try: try:
length_pos_data = get_scalar_constant_value(length_pos) length_pos_data = get_scalar_constant_value(length_pos)
except NotScalarConstantError: except NotScalarConstantError:
......
...@@ -36,7 +36,6 @@ import logging ...@@ -36,7 +36,6 @@ import logging
_logger = logging.getLogger('theano.tensor.opt') _logger = logging.getLogger('theano.tensor.opt')
from theano import gof from theano import gof
from theano.compat import deque
from theano.tensor.elemwise import CAReduce from theano.tensor.elemwise import CAReduce
from theano.tensor import basic as T from theano.tensor import basic as T
......
...@@ -13,7 +13,6 @@ import theano ...@@ -13,7 +13,6 @@ import theano
from theano.gradient import DisconnectedType from theano.gradient import DisconnectedType
from theano import gof from theano import gof
from theano.gof import Apply, Constant, hashtype, Op, Type, MethodNotDefined from theano.gof import Apply, Constant, hashtype, Op, Type, MethodNotDefined
from theano.compat import maxsize
from theano.printing import pprint from theano.printing import pprint
from theano import scalar as scal from theano import scalar as scal
from theano.tensor.basic import alloc from theano.tensor.basic import alloc
...@@ -141,7 +140,7 @@ def get_canonical_form_slice(theslice, length): ...@@ -141,7 +140,7 @@ def get_canonical_form_slice(theslice, length):
(is_start_constant and is_length_constant and (is_start_constant and is_length_constant and
start < 0 and start + length <= 0)) start < 0 and start + length <= 0))
is_stop_length = ( is_stop_length = (
stop is None or stop in [length, maxsize] or stop is None or stop in [length, sys.maxsize] or
(is_stop_constant and is_length_constant and (is_stop_constant and is_length_constant and
stop >= length)) stop >= length))
if is_start_0: if is_start_0:
...@@ -217,7 +216,7 @@ def get_canonical_form_slice(theslice, length): ...@@ -217,7 +216,7 @@ def get_canonical_form_slice(theslice, length):
start = switch(ge(start, length), start = switch(ge(start, length),
switch_neg_step(length - 1, length), switch_neg_step(length - 1, length),
start) start)
if stop is None or stop == maxsize: if stop is None or stop == sys.maxsize:
# The special "maxsize" case is probably not needed here, # The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by # as slices containing maxsize are not generated by
# __getslice__ anymore. # __getslice__ anymore.
...@@ -363,7 +362,7 @@ class Subtensor(Op): ...@@ -363,7 +362,7 @@ class Subtensor(Op):
else: else:
slice_a = None slice_a = None
if b is not None and b != maxsize: if b is not None and b != sys.maxsize:
# The special "maxsize" case is probably not needed here, # The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by # as slices containing maxsize are not generated by
# __getslice__ anymore. # __getslice__ anymore.
...@@ -528,7 +527,7 @@ class Subtensor(Op): ...@@ -528,7 +527,7 @@ class Subtensor(Op):
# If it is the default (None, None, None) slice, or a variant, # If it is the default (None, None, None) slice, or a variant,
# the shape will be xl # the shape will be xl
if ((idx.start in [None, 0]) if ((idx.start in [None, 0])
and (idx.stop in [None, maxsize]) and (idx.stop in [None, sys.maxsize])
and (idx.step is None or idx.step == 1)): and (idx.step is None or idx.step == 1)):
outshp.append(xl) outshp.append(xl)
else: else:
...@@ -647,7 +646,7 @@ class Subtensor(Op): ...@@ -647,7 +646,7 @@ class Subtensor(Op):
is_slice = [] is_slice = []
# TODO: change that, it might lead to unexpected results, # TODO: change that, it might lead to unexpected results,
# see assembla-#767 # see assembla-#767
NONE_CODE = maxsize - 1 NONE_CODE = sys.maxsize - 1
pos = [0, 1] # annoying version of global variable for init_entry pos = [0, 1] # annoying version of global variable for init_entry
...@@ -966,7 +965,7 @@ class SubtensorPrinter: ...@@ -966,7 +965,7 @@ class SubtensorPrinter:
else: else:
msg1 = entry.start msg1 = entry.start
if entry.stop is None or entry.stop == maxsize: if entry.stop is None or entry.stop == sys.maxsize:
msg2 = "" msg2 = ""
else: else:
msg2 = entry.stop msg2 = entry.stop
......
...@@ -25,7 +25,6 @@ from theano.compat.six import StringIO ...@@ -25,7 +25,6 @@ from theano.compat.six import StringIO
from theano import compile, config, function, gof, tensor, shared from theano import compile, config, function, gof, tensor, shared
from theano.compile import DeepCopyOp from theano.compile import DeepCopyOp
from theano.compile.mode import get_default_mode from theano.compile.mode import get_default_mode
from theano.compat import combinations
from theano.tensor import (_shared, wvector, bvector, autocast_float_as, from theano.tensor import (_shared, wvector, bvector, autocast_float_as,
argmin, max_and_argmax, cscalar, ctensor3, join, argmin, max_and_argmax, cscalar, ctensor3, join,
horizontal_stack, vertical_stack, argmax, get_vector_length, horizontal_stack, vertical_stack, argmax, get_vector_length,
...@@ -1928,7 +1927,7 @@ COMPLEX_DTYPES = ALL_DTYPES[-2:] ...@@ -1928,7 +1927,7 @@ COMPLEX_DTYPES = ALL_DTYPES[-2:]
def multi_dtype_checks(shape1, shape2, dtypes=ALL_DTYPES, nameprefix=''): def multi_dtype_checks(shape1, shape2, dtypes=ALL_DTYPES, nameprefix=''):
for dtype1, dtype2 in combinations(dtypes, 2): for dtype1, dtype2 in itertools.combinations(dtypes, 2):
name1 = '%s_%s_%s' % (nameprefix, dtype1, dtype2) name1 = '%s_%s_%s' % (nameprefix, dtype1, dtype2)
name2 = '%s_%s_%s' % (nameprefix, dtype2, dtype1) name2 = '%s_%s_%s' % (nameprefix, dtype2, dtype1)
obj1 = rand_of_dtype(shape1, dtype1) obj1 = rand_of_dtype(shape1, dtype1)
...@@ -1938,7 +1937,7 @@ def multi_dtype_checks(shape1, shape2, dtypes=ALL_DTYPES, nameprefix=''): ...@@ -1938,7 +1937,7 @@ def multi_dtype_checks(shape1, shape2, dtypes=ALL_DTYPES, nameprefix=''):
def multi_dtype_cast_checks(shape, dtypes=ALL_DTYPES, nameprefix=''): def multi_dtype_cast_checks(shape, dtypes=ALL_DTYPES, nameprefix=''):
for dtype1, dtype2 in combinations(dtypes, 2): for dtype1, dtype2 in itertools.combinations(dtypes, 2):
name1 = '%s_%s_%s' % (nameprefix, dtype1, dtype2) name1 = '%s_%s_%s' % (nameprefix, dtype1, dtype2)
name2 = '%s_%s_%s' % (nameprefix, dtype2, dtype1) name2 = '%s_%s_%s' % (nameprefix, dtype2, dtype1)
obj1 = rand_of_dtype(shape, dtype1) obj1 = rand_of_dtype(shape, dtype1)
......
from __future__ import print_function from __future__ import print_function
from copy import copy from copy import copy
from itertools import product as itertools_product
from unittest import TestCase from unittest import TestCase
import numpy import numpy
...@@ -12,7 +13,7 @@ from nose.plugins.attrib import attr ...@@ -12,7 +13,7 @@ from nose.plugins.attrib import attr
import theano import theano
import theano.tensor as T import theano.tensor as T
from theano import tensor, Param, shared, config from theano import tensor, Param, shared, config
from theano.compat import exc_message, product as itertools_product from theano.compat import exc_message
from theano.printing import pp from theano.printing import pp
from theano.tensor.blas import (_dot22, _dot22scalar, res_is_a, _as_scalar, from theano.tensor.blas import (_dot22, _dot22scalar, res_is_a, _as_scalar,
_is_real_matrix, _gemm_canonicalize, _is_real_matrix, _gemm_canonicalize,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论