提交 bfcd85cc authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Apply isort to theano top-level modules

上级 5b6f20c0
...@@ -54,6 +54,7 @@ def disable_log_handler(logger=theano_logger, handler=logging_default_handler): ...@@ -54,6 +54,7 @@ def disable_log_handler(logger=theano_logger, handler=logging_default_handler):
# Version information. # Version information.
from theano.version import version as __version__ from theano.version import version as __version__
# Raise a meaningful warning/error if the theano directory is in the Python # Raise a meaningful warning/error if the theano directory is in the Python
# path. # path.
rpath = os.path.realpath(__path__[0]) rpath = os.path.realpath(__path__[0])
...@@ -65,6 +66,7 @@ for p in sys.path: ...@@ -65,6 +66,7 @@ for p in sys.path:
from theano.configdefaults import config from theano.configdefaults import config
from theano.configparser import change_flags from theano.configparser import change_flags
# This is the api version for ops that generate C code. External ops # This is the api version for ops that generate C code. External ops
# might need manual changes if this number goes up. An undefined # might need manual changes if this number goes up. An undefined
# __api_version__ can be understood to mean api version 0. # __api_version__ can be understood to mean api version 0.
...@@ -73,59 +75,53 @@ from theano.configparser import change_flags ...@@ -73,59 +75,53 @@ from theano.configparser import change_flags
# very rarely. # very rarely.
__api_version__ = 1 __api_version__ = 1
from theano import scalar, tensor
from theano.compile import (
FunctionMaker,
In,
Mode,
OpFromGraph,
Out,
Param,
ProfileStats,
SymbolicInput,
SymbolicOutput,
as_op,
function,
function_dump,
predefined_linkers,
predefined_modes,
predefined_optimizers,
shared,
)
from theano.gof import ( from theano.gof import (
Apply,
CLinker, CLinker,
OpWiseCLinker, Constant,
Container,
DualLinker, DualLinker,
FunctionGraph,
Generic,
InconsistencyError,
Linker, Linker,
LocalLinker, LocalLinker,
PerformLinker,
Container,
InconsistencyError,
FunctionGraph,
Apply,
Variable,
Constant,
Op, Op,
OpenMPOp, OpenMPOp,
opt, OpWiseCLinker,
toolbox, PerformLinker,
Type, Type,
Generic, Variable,
generic, generic,
object2, object2,
opt,
toolbox,
utils, utils,
) )
from theano.gradient import Lop, Rop, grad, subgraph_grad
from theano.compile import (
SymbolicInput,
In,
SymbolicOutput,
Out,
Mode,
predefined_modes,
predefined_linkers,
predefined_optimizers,
FunctionMaker,
function,
function_dump,
OpFromGraph,
ProfileStats,
Param,
shared,
as_op,
)
from theano.misc.safe_asarray import _asarray from theano.misc.safe_asarray import _asarray
from theano.printing import pp, pprint
from theano.printing import pprint, pp
from theano import tensor
from theano import scalar
from theano.updates import OrderedUpdates from theano.updates import OrderedUpdates
from theano.gradient import Rop, Lop, grad, subgraph_grad
if ( if (
config.device.startswith("cuda") config.device.startswith("cuda")
...@@ -139,6 +135,7 @@ if ( ...@@ -139,6 +135,7 @@ if (
# Use config.numpy to call numpy.seterr # Use config.numpy to call numpy.seterr
import numpy as np import numpy as np
if config.numpy.seterr_all == "None": if config.numpy.seterr_all == "None":
_all = None _all = None
else: else:
...@@ -219,5 +216,4 @@ def sparse_grad(var): ...@@ -219,5 +216,4 @@ def sparse_grad(var):
import theano.tensor.shared_randomstreams import theano.tensor.shared_randomstreams
from theano.scan_module import clone, foldl, foldr, map, reduce, scan, scan_checkpoints
from theano.scan_module import scan, map, reduce, foldl, foldr, clone, scan_checkpoints
...@@ -2,8 +2,7 @@ import numpy as np ...@@ -2,8 +2,7 @@ import numpy as np
import theano import theano
import theano.tensor as tt import theano.tensor as tt
from theano.gof import Apply, Op
from theano.gof import Op, Apply
from theano.gradient import DisconnectedType from theano.gradient import DisconnectedType
......
...@@ -2,31 +2,25 @@ ...@@ -2,31 +2,25 @@
""" """
from collections import OrderedDict
# Python 3.x compatibility # Python 3.x compatibility
from six import PY3, b, BytesIO, next from six import PY3, BytesIO, b, next
from six.moves import configparser from six.moves import configparser
from six.moves import reload_module as reload from six.moves import reload_module as reload
from collections import OrderedDict
try: try:
from collections.abc import ( from collections.abc import Callable, Iterable, Mapping
Callable, from collections.abc import MutableMapping as DictMixin
Iterable, from collections.abc import ValuesView
Mapping,
ValuesView,
MutableMapping as DictMixin,
)
except ImportError: except ImportError:
# this raises an DeprecationWarning on py37 and will become # this raises an DeprecationWarning on py37 and will become
# and Exception in py39. Importing from collections.abc # and Exception in py39. Importing from collections.abc
# won't work on py27 # won't work on py27
from collections import ( from collections import Callable, Iterable, Mapping
Callable, from collections import MutableMapping as DictMixin
Iterable, from collections import ValuesView
Mapping,
ValuesView,
MutableMapping as DictMixin,
)
__all__ = ["PY3", "b", "BytesIO", "next", "configparser", "reload"] __all__ = ["PY3", "b", "BytesIO", "next", "configparser", "reload"]
...@@ -66,9 +60,10 @@ if PY3: ...@@ -66,9 +60,10 @@ if PY3:
else: else:
from six import get_unbound_function
from operator import div as operator_div from operator import div as operator_div
from six import get_unbound_function
def exc_message(e): def exc_message(e):
return e[0] return e[0]
......
import errno import errno
import os
import sys
import logging import logging
import numpy as np import os
import platform import platform
import textwrap
import re import re
import socket import socket
import struct import struct
import sys
import textwrap
import warnings import warnings
import numpy as np
from six import string_types from six import string_types
import theano import theano
from theano.compat import maybe_add_to_os_environ_pathlist
from theano.configparser import ( from theano.configparser import (
THEANO_FLAGS_DICT,
AddConfigVar, AddConfigVar,
BoolParam, BoolParam,
ConfigParam, ConfigParam,
...@@ -22,11 +24,9 @@ from theano.configparser import ( ...@@ -22,11 +24,9 @@ from theano.configparser import (
IntParam, IntParam,
StrParam, StrParam,
TheanoConfigParser, TheanoConfigParser,
THEANO_FLAGS_DICT,
) )
from theano.misc.cpucount import cpuCount from theano.misc.cpucount import cpuCount
from theano.misc.windows import call_subprocess_Popen, output_subprocess_Popen from theano.misc.windows import call_subprocess_Popen, output_subprocess_Popen
from theano.compat import maybe_add_to_os_environ_pathlist
_logger = logging.getLogger("theano.configdefaults") _logger = logging.getLogger("theano.configdefaults")
...@@ -1668,6 +1668,7 @@ def default_blas_ldflags(): ...@@ -1668,6 +1668,7 @@ def default_blas_ldflags():
# ignored" # ignored"
# This happen with Python 2.7.3 |EPD 7.3-1 and numpy 1.8.1 # This happen with Python 2.7.3 |EPD 7.3-1 and numpy 1.8.1
# isort: off
import numpy.distutils.system_info # noqa import numpy.distutils.system_info # noqa
# We need to catch warnings as in some cases NumPy print # We need to catch warnings as in some cases NumPy print
......
...@@ -8,14 +8,14 @@ import os ...@@ -8,14 +8,14 @@ import os
import shlex import shlex
import sys import sys
import warnings import warnings
import theano
from functools import wraps from functools import wraps
from six import StringIO, PY3, string_types from six import PY3, StringIO, string_types
import theano
from theano.compat import configparser as ConfigParser from theano.compat import configparser as ConfigParser
_logger = logging.getLogger("theano.configparser") _logger = logging.getLogger("theano.configparser")
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
import logging import logging
import time import time
import warnings import warnings
from collections import OrderedDict
from functools import reduce
import numpy as np # for numeric_grad import numpy as np
import theano import theano
from functools import reduce
from collections import OrderedDict
from theano import gof from theano import gof
from theano.gof import utils, Variable from theano.compile.debugmode import DebugMode
from theano.compile.mode import FAST_RUN, get_mode
from theano.compile.ops import ViewOp
from theano.gof import Variable, utils
from theano.gof.null_type import NullType, null_type from theano.gof.null_type import NullType, null_type
from theano.gof.op import get_test_values from theano.gof.op import get_test_values
from theano.compile import ViewOp, FAST_RUN, DebugMode, get_mode
__authors__ = "James Bergstra, Razvan Pascanu, Arnaud Bergeron, Ian Goodfellow" __authors__ = "James Bergstra, Razvan Pascanu, Arnaud Bergeron, Ian Goodfellow"
__copyright__ = "(c) 2011, Universite de Montreal" __copyright__ = "(c) 2011, Universite de Montreal"
...@@ -1790,9 +1790,9 @@ def verify_grad( ...@@ -1790,9 +1790,9 @@ def verify_grad(
""" """
# The import is here to prevent circular import. # The import is here to prevent circular import.
from theano import compile, shared
import theano.tensor import theano.tensor
from theano.tensor import as_tensor_variable, TensorType from theano import compile, shared
from theano.tensor import TensorType, as_tensor_variable
assert isinstance(pt, (list, tuple)) assert isinstance(pt, (list, tuple))
pt = [np.array(p) for p in pt] pt = [np.array(p) for p in pt]
......
...@@ -12,20 +12,16 @@ is a global operation with a scalar condition. ...@@ -12,20 +12,16 @@ is a global operation with a scalar condition.
""" """
import logging import logging
from copy import deepcopy
import numpy as np import numpy as np
import theano.tensor import theano.tensor
from copy import deepcopy
from theano.tensor import TensorType
from theano import gof from theano import gof
from theano.gof import Op, Apply
from theano.compile import optdb from theano.compile import optdb
from theano.tensor import opt from theano.gof import Apply, Op
from theano.scan_module.scan_utils import clone from theano.scan_module.scan_utils import clone
from theano.tensor import TensorType, opt
__docformat__ = "restructedtext en" __docformat__ = "restructedtext en"
......
...@@ -4,26 +4,22 @@ They all allow different way to print a graph or the result of an Op ...@@ -4,26 +4,22 @@ They all allow different way to print a graph or the result of an Op
in a graph(Print Op) in a graph(Print Op)
""" """
import hashlib
import logging import logging
import os import os
import sys import sys
import hashlib from copy import copy
from functools import reduce
import numpy as np import numpy as np
from six import integer_types, string_types
from six.moves import StringIO
import theano import theano
from theano import config, gof
from theano.compile import Function, SharedVariable, debugmode
from theano.gof import Apply, Op
from functools import reduce
from copy import copy
from six import string_types, integer_types
from six.moves import StringIO
from theano import gof
from theano import config
from theano.gof import Op, Apply
from theano.compile import Function, debugmode, SharedVariable
pydot_imported = False pydot_imported = False
pydot_imported_msg = "" pydot_imported_msg = ""
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
from theano import gof from theano import gof
__authors__ = "James Bergstra" __authors__ = "James Bergstra"
__copyright__ = "(c) 2011, Universite de Montreal" __copyright__ = "(c) 2011, Universite de Montreal"
__license__ = "3-clause BSD License" __license__ = "3-clause BSD License"
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
""" """
import logging import logging
import warnings import warnings
from collections import OrderedDict from collections import OrderedDict
from theano.compile.sharedvalue import SharedVariable from theano.compile.sharedvalue import SharedVariable
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论