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

Apply isort to tests.tensor sub-package top-level modules

上级 6c8cb50e
# Run using
# mpiexec -np 2 python _test_mpi_roundtrip.py
from sys import exit, stderr, stdout
import numpy as np
from mpi4py import MPI
import theano
from theano.configparser import change_flags
from theano.tensor.io import send, recv, mpi_cmps
from theano.gof.sched import sort_schedule_fn
import numpy as np
from sys import stdout, stderr, exit
from theano.tensor.io import mpi_cmps, recv, send
comm = MPI.COMM_WORLD
......
import builtins
import itertools
import operator
import os
import warnings
import builtins
import pytest
from copy import copy, deepcopy
from functools import partial, reduce
from tempfile import mkstemp
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_almost_equal, assert_array_equal
import theano
import theano.tensor as tt
from tempfile import mkstemp
from copy import copy, deepcopy
from functools import partial, reduce
from numpy.testing import assert_array_equal, assert_allclose, assert_almost_equal
from theano import change_flags
from tests import unittest_tools as utt
from theano import change_flags, compile, config, function, gof, shared
from theano.compat import operator_div
from theano import compile, config, function, gof, shared
from theano.compile import DeepCopyOp
from theano.compile.mode import get_default_mode
from theano.scalar import autocast_float_as, autocast_float
from theano.scalar import autocast_float, autocast_float_as
from theano.tensor import (
wvector,
bvector,
argmin,
max_and_argmax,
cscalar,
join,
horizontal_stack,
vertical_stack,
argmax,
get_vector_length,
fscalar,
sum,
tensor3,
vector,
Alloc,
AllocDiag,
AllocEmpty,
ARange,
Argmax,
Choose,
DimShuffle,
Dot,
ExtractDiag,
Eye,
Join,
MaxAndArgmax,
Mean,
NoneConst,
PermuteRowElements,
Rebroadcast,
Reshape,
ScalarFromTensor,
Shape,
SpecifyShape,
Split,
Tensor,
TensorFromScalar,
TensorType,
Tile,
Tri,
add,
addbroadcast,
allclose,
alloc,
arange,
argmax,
argmin,
as_tensor_variable,
tensor_from_scalar,
ARange,
batched_dot,
bvector,
choose,
clip,
constant,
cscalar,
default,
diag,
dot,
batched_dot,
dmatrix,
dot,
dscalar,
dscalars,
dtensor3,
dtensor4,
dvector,
eq,
exp,
extract_constant,
eye,
fill,
flatnonzero,
flatten,
inverse_permutation,
tensor4,
permute_row_elements,
fmatrix,
fscalar,
fscalars,
fvector,
get_scalar_constant_value,
get_vector_length,
grad,
hessian,
horizontal_stack,
imatrix,
inplace,
inverse_permutation,
iscalar,
matrix,
minimum,
iscalars,
isclose,
itensor3,
ivector,
join,
lscalar,
lvector,
matrices,
matrix,
max,
max_and_argmax,
maximum,
mgrid,
min,
minimum,
mul,
neq,
Reshape,
nonzero,
nonzero_values,
numeric_grad,
ogrid,
opt,
patternbroadcast,
permute_row_elements,
power,
ptp,
reshape,
roll,
row,
scal,
scalar,
scalar_from_tensor,
scalars,
second,
shape,
smallest,
stack,
stacklists,
sub,
Tensor,
sum,
swapaxes,
switch,
tensor3,
tensor4,
tensor_copy,
tensor_from_scalar,
tensordot,
TensorType,
Tri,
tile,
tri,
tril,
triu,
true_div,
unbroadcast,
var,
Argmax,
Join,
shape,
MaxAndArgmax,
lscalar,
vector,
vertical_stack,
wvector,
zvector,
exp,
get_scalar_constant_value,
ivector,
reshape,
scalar_from_tensor,
scal,
iscalars,
arange,
dscalars,
fvector,
imatrix,
numeric_grad,
opt,
lvector,
true_div,
max,
min,
Split,
roll,
tile,
patternbroadcast,
Eye,
Shape,
Dot,
PermuteRowElements,
ScalarFromTensor,
TensorFromScalar,
dtensor4,
Rebroadcast,
Alloc,
dtensor3,
SpecifyShape,
Mean,
itensor3,
Tile,
switch,
ExtractDiag,
AllocDiag,
nonzero,
flatnonzero,
nonzero_values,
stacklists,
DimShuffle,
hessian,
ptp,
power,
swapaxes,
choose,
Choose,
NoneConst,
AllocEmpty,
isclose,
allclose,
mgrid,
ogrid,
extract_constant,
)
from tests import unittest_tools as utt
imported_scipy_special = False
mode_no_scipy = get_default_mode()
......
import pytest
import numpy as np
import theano
import theano.tensor as tt
import theano.tensor.blas_scipy
from copy import copy
from itertools import product
import numpy as np
import pytest
from numpy import (
arange,
array,
......@@ -25,38 +18,40 @@ from numpy import (
)
from numpy.testing import assert_array_almost_equal
from theano import In, shared, config
import theano
import theano.tensor as tt
import theano.tensor.blas_scipy
from tests import unittest_tools
from tests.tensor.test_basic import as_tensor_variable, compile, inplace, inplace_func
from theano import In, config, shared
from theano.tensor.blas import (
Dot22,
Dot22Scalar,
Gemm,
Gemv,
Ger,
InconsistencyError,
_as_scalar,
_dot22,
_dot22scalar,
res_is_a,
_as_scalar,
_is_real_matrix,
_gemm_canonicalize,
_factor_canonicalized,
Gemm,
Gemv,
_gemm_canonicalize,
_is_real_matrix,
gemm,
gemm_inplace,
gemm_no_inplace,
InconsistencyError,
Ger,
gemv,
gemv_inplace,
gemv_no_inplace,
ger,
ger_destructive,
Dot22,
Dot22Scalar,
gemm,
local_dot22_to_dot22scalar,
gemv_no_inplace,
gemv,
gemv_inplace,
local_gemm_to_ger,
res_is_a,
)
from theano.tensor.nnet import sigmoid
from theano.tensor.opt import in2out
from tests import unittest_tools
from tests.tensor.test_basic import as_tensor_variable, inplace_func, compile, inplace
if config.mode == "FAST_COMPILE":
mode_not_fast_compile = "FAST_RUN"
......
import sys
import pytest
import numpy as np
import pytest
import theano
import theano.tensor as tensor
from tests import unittest_tools
from tests.tensor.test_blas import BaseGemv, TestBlasStrides
from tests.unittest_tools import OptimizationTestMixin
from theano.tensor.blas import Ger
from theano.tensor.blas_c import CGer
from theano.tensor.blas_c import CGemv, CGer, check_force_gemv_init
from theano.tensor.blas_scipy import ScipyGer
from theano.tensor.blas_c import CGemv, check_force_gemv_init
from tests import unittest_tools
from tests.unittest_tools import OptimizationTestMixin
from tests.tensor.test_blas import BaseGemv, TestBlasStrides
mode_blas_opt = theano.compile.get_default_mode().including(
"BlasOpt", "specialize", "InplaceBlasOpt", "c_blas"
......
import numpy as np
import pytest
import theano
import theano.tensor as tensor
from theano.tensor.blas_scipy import ScipyGer
from tests.tensor.test_blas import TestBlasStrides, gemm_no_inplace
from tests.unittest_tools import OptimizationTestMixin
from tests.tensor.test_blas import gemm_no_inplace, TestBlasStrides
from theano.tensor.blas_scipy import ScipyGer
@pytest.mark.skipif(not theano.tensor.blas_scipy.have_fblas, reason="fblas needed")
......
import numpy as np
import theano
import theano.tensor.basic as basic
from theano import function
from theano.tensor.basic import (
_convert_to_int32,
_convert_to_int8,
_convert_to_int16,
_convert_to_int64,
_convert_to_float32,
_convert_to_float64,
)
from theano.compile import In
from theano.tensor import (
TensorType,
bvector,
ivector,
fvector,
dvector,
zmatrix,
cast,
TensorType,
dmatrix,
dvector,
fvector,
ivector,
zmatrix,
)
from theano.tensor.basic import (
_convert_to_float32,
_convert_to_float64,
_convert_to_int8,
_convert_to_int16,
_convert_to_int32,
_convert_to_int64,
)
from theano.compile import In
class TestCasting:
......
import pytest
import numpy as np
import pytest
import theano
from tests import unittest_tools as utt
from theano.tensor import (
real,
imag,
zvector,
dvector,
cast,
complex,
complex_from_polar,
cvector,
dvector,
fmatrix,
fvector,
cvector,
imag,
imatrix,
complex,
complex_from_polar,
real,
zvector,
)
from tests import unittest_tools as utt
class TestRealImag:
def test_basic(self):
......
import math
import six.moves.cPickle as pickle
import pytest
from copy import copy
import numpy as np
import pytest
import six.moves.cPickle as pickle
import tests.unittest_tools as utt
import theano
import theano.tensor as tt
import tests.unittest_tools as utt
from copy import copy
from theano import gof, scalar, config
from tests import unittest_tools
from theano import config, gof, scalar
from theano.compile.mode import Mode, get_default_mode
from theano.tensor import TensorType, as_tensor_variable
from theano.compile.mode import get_default_mode, Mode
from theano.tensor.elemwise import (
CAReduce,
Elemwise,
DimShuffle,
Elemwise,
Prod,
ProdWithoutZeros,
Sum,
)
from theano.tensor.type import values_eq_approx_remove_nan
from theano.tensor.nnet import sigmoid
from tests import unittest_tools
from theano.tensor.type import values_eq_approx_remove_nan
def FunctionGraph(i, o):
......
import pytest
import numpy as np
import pytest
import theano
from tests import unittest_tools as utt
from theano import config, function
from theano import tensor as tt
from theano.tensor.extra_ops import (
SearchsortedOp,
searchsorted,
CumOp,
cumsum,
cumprod,
Bartlett,
CpuContiguous,
cpu_contiguous,
bincount,
CumOp,
DiffOp,
diff,
squeeze,
compress,
FillDiagonal,
FillDiagonalOffset,
RavelMultiIndex,
RepeatOp,
repeat,
Bartlett,
SearchsortedOp,
Unique,
UnravelIndex,
bartlett,
FillDiagonal,
bincount,
broadcast_shape,
compress,
cpu_contiguous,
cumprod,
cumsum,
diff,
fill_diagonal,
FillDiagonalOffset,
fill_diagonal_offset,
ravel_multi_index,
repeat,
searchsorted,
squeeze,
to_one_hot,
Unique,
unravel_index,
UnravelIndex,
ravel_multi_index,
RavelMultiIndex,
broadcast_shape,
)
from theano import tensor as tt
from theano import config, function
from tests import unittest_tools as utt
def test_cpu_contiguous():
......
......@@ -3,10 +3,8 @@ import pytest
import theano
import theano.tensor as tt
from theano.tensor import fft
from tests import unittest_tools as utt
from theano.tensor import fft
N = 16
......
import pytest
import numpy as np
import pytest
import theano
from tests import unittest_tools as utt
from theano import tensor
from theano.tensor.fourier import Fourier, fft
from tests import unittest_tools as utt
class TestFourier(utt.InferShapeTester):
......
import time
import six.moves.cPickle as pickle
import numpy as np
import six.moves.cPickle as pickle
import theano
import theano.tensor as tt
......
import numpy as np
import pytest
import theano
import theano.tensor as tt
from tests import unittest_tools as utt
......
import theano
import pytest
from theano import tensor, function, Variable, Generic
import numpy as np
import os
import numpy as np
import pytest
import theano
from theano import Generic, Variable, function, tensor
class TestLoadTensor:
def setup_method(self):
......
......@@ -3,7 +3,7 @@ import pytest
from six import integer_types
import theano
from theano import tensor, function
from theano import function, tensor
# this tests other ops to ensure they keep the dimensions of their
......
import numpy as np
import theano.tensor.basic as tt
from theano.gof.type import Type
from theano.gof.graph import Variable, Apply
import theano.tensor.basic as tt
from theano.gof.fg import FunctionGraph
from theano.gof.graph import Apply, Variable
from theano.gof.op import Op
from theano.gof.opt import MergeOptimizer
from theano.gof.fg import FunctionGraph
from theano.gof.type import Type
def is_variable(x):
......
import copy
import numpy as np
import theano
from theano import tensor
from theano.tensor.nnet import crossentropy_softmax_argmax_1hot_with_bias
......
import os
import subprocess
import pytest
import theano
from theano import change_flags
from theano.gof.sched import sort_schedule_fn
from theano.tensor.io import (
send,
recv,
mpi_cmps,
MPISend,
MPISendWait,
mpi_send_wait_cmp,
mpi_cmps,
mpi_enabled,
mpi_send_wait_cmp,
recv,
send,
)
mpi_scheduler = sort_schedule_fn(*mpi_cmps)
mpi_linker = theano.OpWiseCLinker(schedule=mpi_scheduler)
mpi_mode = theano.Mode(linker=mpi_linker)
......
import pytest
import numpy as np
import numpy.linalg
import theano
import pytest
from numpy import inf
from numpy.testing import assert_array_almost_equal
from theano import tensor, function
from theano.tensor.basic import _allclose
from theano import config
import theano
from tests import unittest_tools as utt
from theano import config, function, tensor
from theano.configparser import change_flags
from theano.tensor.basic import _allclose
from theano.tensor.nlinalg import (
MatrixInverse,
matrix_inverse,
pinv,
SVD,
AllocDiag,
alloc_diag,
Eig,
ExtractDiag,
extract_diag,
diag,
trace,
MatrixInverse,
TensorInv,
alloc_diag,
det,
Eig,
diag,
eig,
eigh,
extract_diag,
matrix_dot,
qr,
matrix_inverse,
matrix_power,
norm,
pinv,
qr,
svd,
SVD,
TensorInv,
tensorinv,
tensorsolve,
trace,
)
from tests import unittest_tools as utt
def test_pseudoinverse_correctness():
rng = np.random.RandomState(utt.fetch_seed())
......
......@@ -4,13 +4,13 @@ import time
import numpy as np
import pytest
from six import StringIO
import theano
import theano.scalar as scal
import theano.tensor as tt
import theano.tensor.opt as opt
from six import StringIO
from tests import unittest_tools as utt
from theano import change_flags, compile, config, function, gof, pprint, shared
from theano.compile import DeepCopyOp, deep_copy_op, get_mode
from theano.gof import FunctionGraph
......@@ -47,12 +47,15 @@ from theano.tensor import (
vectors,
)
from theano.tensor.basic import _convert_to_int8
from theano.tensor.blas import Dot22, Gemv
from theano.tensor.blas_c import CGemv
from theano.tensor.elemwise import DimShuffle, Elemwise, Prod
from theano.tensor.nnet.sigm import softplus
from theano.tensor.opt import (
Assert,
assert_op,
MakeVector,
Shape_i,
assert_op,
local_add_specialize,
local_canonicalize_alloc,
local_dimshuffle_lift,
......@@ -66,11 +69,7 @@ from theano.tensor.opt import (
mul_canonizer,
)
from theano.tensor.type import values_eq_approx_remove_nan
from theano.tensor.blas_c import CGemv
from theano.tensor.blas import Dot22, Gemv
from theano.tensor.nnet.sigm import softplus
from tests import unittest_tools as utt
mode_opt = theano.config.mode
if mode_opt == "FAST_COMPILE":
......
import numpy as np
import theano
from theano import function, config
from theano import scalar
import theano.tensor as tensor
from tests import unittest_tools as utt
from theano import config, function, scalar
from theano.gof import FunctionGraph
from theano.gof.opt import out2in
# from theano.tensor import matrix,max_and_argmax,MaaxAndArgmax,neg
from theano.tensor.elemwise import CAReduce, DimShuffle, Elemwise
from theano.tensor.opt_uncanonicalize import (
local_alloc_dimshuffle,
local_reshape_dimshuffle,
local_dimshuffle_alloc,
local_dimshuffle_subtensor,
local_reshape_dimshuffle,
)
import theano.tensor as tensor
# from theano.tensor import matrix,max_and_argmax,MaaxAndArgmax,neg
from theano.tensor.elemwise import CAReduce, Elemwise, DimShuffle
from tests import unittest_tools as utt
class TestMaxAndArgmax:
......
import pickle
import numpy as np
import pytest
import theano
from theano import tensor, compile, config
from tests import unittest_tools as utt
from theano import compile, config, tensor
from theano.tensor import dcol, dvector, ivector, raw_random
from theano.tensor.raw_random import (
RandomFunction,
random_state_type,
uniform,
poisson,
normal,
binomial,
choice,
random_integers,
multinomial,
normal,
permutation,
permutation_helper,
poisson,
random_integers,
random_state_type,
uniform,
)
from theano.tensor import raw_random, ivector, dvector, dcol
from tests import unittest_tools as utt
__docformat__ = "restructuredtext en"
......
import pytest
import numpy as np
from theano import function, shared, tensor, config
from theano.tensor.shared_randomstreams import RandomStreams
import pytest
from tests import unittest_tools as utt
from theano import config, function, shared, tensor
from theano.tensor.shared_randomstreams import RandomStreams
class TestSharedRandomStreams:
......
import pytest
import six
from functools import update_wrapper
import numpy as np
import pytest
import six
import theano
import theano.sparse
from functools import update_wrapper
from tests import unittest_tools as utt
from theano import tensor
from theano.misc.may_share_memory import may_share_memory
from tests import unittest_tools as utt
utt.seed_rng()
......
import itertools
import pytest
import numpy as np
import numpy.linalg
import pytest
import theano
from theano import tensor, function, grad, config
from tests import unittest_tools as utt
from theano import config, function, grad, tensor
from theano.tensor.slinalg import (
Cholesky,
cholesky,
CholeskyGrad,
Solve,
solve,
cholesky,
eigvalsh,
expm,
kron,
solve,
)
from tests import unittest_tools as utt
def check_lower_triangular(pd, ch_f):
ch = ch_f(pd)
......
from itertools import product, chain
from functools import reduce
from tests import unittest_tools as utt
from itertools import chain, product
import numpy as np
import pytest
import theano
from tests import unittest_tools as utt
from theano import tensor
from theano.tensor.sort import (
ArgSortOp,
SortOp,
TopKOp,
argsort,
argtopk,
sort,
topk,
topk_and_argtopk,
)
from theano.tensor.sort import sort, SortOp
from theano.tensor.sort import argsort, ArgSortOp
from theano.tensor.sort import topk, argtopk, topk_and_argtopk, TopKOp
_all_dtypes = tensor.integer_dtypes + tensor.float_dtypes
......
import logging
import sys
import pytest
import numpy as np
import pytest
from numpy.testing import assert_array_equal
from six import StringIO
import theano
import theano.scalar as scal
import theano.tensor as tt
from numpy.testing import assert_array_equal
from six import StringIO
from theano import config, change_flags
from tests import unittest_tools as utt
from tests.tensor.test_basic import inplace_func, rand, randint_ranged
from theano import change_flags, config
from theano.compile import DeepCopyOp
from theano.gof.op import get_test_value
from theano.gof.toolbox import is_same_graph
......@@ -27,8 +25,8 @@ from theano.tensor import (
dvector,
fmatrix,
fscalar,
fvector,
ftensor4,
fvector,
iscalar,
lmatrix,
lrow,
......@@ -38,27 +36,24 @@ from theano.tensor import (
)
from theano.tensor.basic import DimShuffle
from theano.tensor.subtensor import (
basic_shape,
indexed_result_shape,
Subtensor,
IncSubtensor,
AdvancedIncSubtensor,
AdvancedIncSubtensor1,
AdvancedSubtensor,
AdvancedSubtensor1,
IncSubtensor,
Subtensor,
advanced_inc_subtensor,
advanced_inc_subtensor1,
advanced_set_subtensor,
advanced_set_subtensor1,
basic_shape,
get_canonical_form_slice,
inc_subtensor,
indexed_result_shape,
set_subtensor,
)
from theano.tensor.type_other import make_slice
from tests import unittest_tools as utt
from tests.tensor.test_basic import inplace_func, rand, randint_ranged
subtensor_ops = (
Subtensor,
......
......@@ -2,7 +2,7 @@
import theano
from theano.gof import Constant
from theano.tensor.type_other import MakeSlice, make_slice, NoneTypeT, NoneConst
from theano.tensor.type_other import MakeSlice, NoneConst, NoneTypeT, make_slice
def test_make_slice_merge():
......@@ -30,6 +30,7 @@ def test_none_Constant():
# This trigger equals that returned the wrong answer in the past.
import six.moves.cPickle as pickle
import theano
from theano import tensor
......
import pytest
import numpy as np
import theano
import pytest
import theano
from theano.tensor.utils import hash_from_ndarray, shape_of_variables
......
import numpy as np
import pytest
from numpy.testing import assert_equal, assert_string_equal
import tests.unittest_tools as utt
import theano
import theano.tensor as tt
from numpy.testing import assert_equal, assert_string_equal
from theano.tensor.var import TensorConstant
from theano.tensor.subtensor import (
Subtensor,
AdvancedSubtensor,
AdvancedSubtensor1,
)
from theano.tensor.elemwise import DimShuffle
from theano.tensor.subtensor import AdvancedSubtensor, AdvancedSubtensor1, Subtensor
from theano.tensor.type_other import MakeSlice
import tests.unittest_tools as utt
from theano.tensor.var import TensorConstant
@pytest.mark.parametrize(
......
import theano
import numpy.random
import theano
from tests import unittest_tools as utt
from theano.tensor import as_tensor_variable
from theano.tensor.xlogx import xlogx, xlogy0
from tests import unittest_tools as utt
class TestXlogX:
def setup_method(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论