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