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

Apply isort to tests.gof sub-package modules

上级 ed04fa8a
import pytest
import numpy as np import numpy as np
import pytest
import theano import theano
from theano.gof.link import PerformLinker from theano.gof import fg
from theano.gof.cc import CLinker, DualLinker, OpWiseCLinker from theano.gof.cc import CLinker, DualLinker, OpWiseCLinker
from theano.gof.type import Type from theano.gof.graph import Apply, Constant, Variable
from theano.gof.graph import Variable, Apply, Constant from theano.gof.link import PerformLinker
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof import fg from theano.gof.type import Type
def as_variable(x): def as_variable(x):
......
import os
import sys
import traceback
import warnings import warnings
import pytest
import numpy as np import numpy as np
import pytest
import theano import theano
import theano.tensor as tt import theano.tensor as tt
from theano import config, scalar from theano import config, scalar
from theano.gof import Apply, Op, utils from theano.gof import Apply, Op, utils
from theano.tensor.basic import _allclose from theano.tensor.basic import _allclose
...@@ -222,21 +218,12 @@ class TestComputeTestValue: ...@@ -222,21 +218,12 @@ class TestComputeTestValue:
def fx(prior_result, A): def fx(prior_result, A):
return tt.dot(prior_result, A) return tt.dot(prior_result, A)
# Since we have to inspect the traceback, with pytest.raises(ValueError) as e:
# we cannot simply use self.assertRaises()
with pytest.raises(ValueError):
theano.scan(fn=fx, outputs_info=tt.ones_like(A), non_sequences=A, n_steps=k) theano.scan(fn=fx, outputs_info=tt.ones_like(A), non_sequences=A, n_steps=k)
# Get traceback assert str(e.traceback[0].path).endswith("test_compute_test_value.py")
tb = sys.exc_info()[2]
frame_infos = traceback.extract_tb(tb)
# We should be in the "fx" function defined above # We should be in the "fx" function defined above
expected = "test_compute_test_value.py" assert e.traceback[2].name == "fx"
assert any(
(os.path.split(frame_info[0])[1] == expected and frame_info[2] == "fx")
for frame_info in frame_infos
), frame_infos
@theano.change_flags(compute_test_value="raise") @theano.change_flags(compute_test_value="raise")
def test_scan_err2(self): def test_scan_err2(self):
...@@ -255,8 +242,6 @@ class TestComputeTestValue: ...@@ -255,8 +242,6 @@ class TestComputeTestValue:
fn=fx, outputs_info=tt.ones_like(A.T), non_sequences=A, n_steps=k fn=fx, outputs_info=tt.ones_like(A.T), non_sequences=A, n_steps=k
) )
# Since we have to inspect the traceback,
# we cannot simply use self.assertRaises()
with pytest.raises(ValueError, match="^could not broadcast input"): with pytest.raises(ValueError, match="^could not broadcast input"):
theano.scan( theano.scan(
fn=fx, outputs_info=tt.ones_like(A.T), non_sequences=A, n_steps=k fn=fx, outputs_info=tt.ones_like(A.T), non_sequences=A, n_steps=k
......
import pytest
from copy import copy from copy import copy
from theano.gof.type import Type import pytest
from theano.gof import graph
from theano.gof.graph import Variable, Apply from tests.unittest_tools import assertFailure_fast
from theano import change_flags
from theano.gof import destroyhandler, graph
from theano.gof.fg import FunctionGraph, InconsistencyError
from theano.gof.graph import Apply, Variable
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof.opt import ( from theano.gof.opt import (
NavigatorOptimizer,
OpKeyOptimizer, OpKeyOptimizer,
OpSub,
PatternSub, PatternSub,
NavigatorOptimizer,
TopoOptimizer, TopoOptimizer,
OpSub,
) )
from theano import change_flags
from theano.gof import destroyhandler
from theano.gof.fg import FunctionGraph, InconsistencyError
from theano.gof.toolbox import ReplaceValidate from theano.gof.toolbox import ReplaceValidate
from theano.gof.type import Type
from tests.unittest_tools import assertFailure_fast
def PatternOptimizer(p1, p2, ign=True): def PatternOptimizer(p1, p2, ign=True):
......
import pickle import pickle
from itertools import count
import pytest
import numpy as np import numpy as np
import pytest
from itertools import count from theano import shared, sparse, tensor
from theano import sparse, shared, tensor
from theano.gof.graph import ( from theano.gof.graph import (
Apply, Apply,
Variable,
as_string, as_string,
clone, clone,
equal_computations,
general_toposort, general_toposort,
inputs, inputs,
io_toposort, io_toposort,
Variable,
equal_computations,
) )
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof.type import Type from theano.gof.type import Type
......
import os import os
import numpy as np import numpy as np
import theano import theano
import theano.tensor as tt import theano.tensor as tt
floatX = "float32" floatX = "float32"
......
import pytest from copy import deepcopy
import numpy as np import numpy as np
import pytest
import theano import theano
import theano.tensor as tt import theano.tensor as tt
from theano import Mode, function
from copy import deepcopy
from theano import function, Mode
from theano.gof import Apply, generic from theano.gof import Apply, generic
from theano.gof.op import PureOp from theano.gof.op import PureOp
from theano.ifelse import ifelse from theano.ifelse import ifelse
......
...@@ -3,14 +3,12 @@ from copy import deepcopy ...@@ -3,14 +3,12 @@ from copy import deepcopy
import numpy as np import numpy as np
import theano import theano
from theano.gof import graph
from theano.gof.graph import Variable, Apply, Constant
from theano.gof.type import Type
from theano.gof.op import Op
from theano.gof import fg
from theano.gof.link import PerformLinker, WrapLinker, Container
from theano.compat import cmp from theano.compat import cmp
from theano.gof import fg, graph
from theano.gof.graph import Apply, Constant, Variable
from theano.gof.link import Container, PerformLinker, WrapLinker
from theano.gof.op import Op
from theano.gof.type import Type
def as_variable(x): def as_variable(x):
...@@ -175,7 +173,7 @@ class TestWrapLinker: ...@@ -175,7 +173,7 @@ class TestWrapLinker:
def test_sort_schedule_fn(): def test_sort_schedule_fn():
import theano import theano
from theano.gof.sched import sort_schedule_fn, make_depends from theano.gof.sched import make_depends, sort_schedule_fn
x = theano.tensor.matrix("x") x = theano.tensor.matrix("x")
y = theano.tensor.dot(x[:5] * 2, x.T + 1).T y = theano.tensor.dot(x[:5] * 2, x.T + 1).T
......
import numpy as np import numpy as np
import pytest import pytest
from six import string_types
import theano import theano
import theano.gof.op as op import theano.gof.op as op
import theano.tensor as tt import theano.tensor as tt
from theano import config, scalar, shared
from six import string_types
from theano import scalar, shared, config
from theano.configparser import change_flags from theano.configparser import change_flags
from theano.gof.graph import Apply, Variable from theano.gof.graph import Apply, Variable
from theano.gof.type import Generic, Type
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof.utils import TestValueError, MethodNotDefined from theano.gof.type import Generic, Type
from theano.gof.utils import MethodNotDefined, TestValueError
def as_variable(x): def as_variable(x):
......
import theano.tensor as tt import theano.tensor as tt
from theano.gof.fg import FunctionGraph
from theano.gof.type import Type from theano.gof.graph import Apply, Constant, Variable
from theano.gof.graph import Variable, Apply, Constant
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof.opt import ( from theano.gof.opt import (
EquilibriumOptimizer,
MergeOptimizer,
OpKeyOptimizer, OpKeyOptimizer,
OpSub,
PatternSub, PatternSub,
TopoOptimizer, TopoOptimizer,
OpSub,
MergeOptimizer,
config, config,
theano,
EquilibriumOptimizer,
logging, logging,
pre_constant_merge, pre_constant_merge,
pre_greedy_local_optimizer, pre_greedy_local_optimizer,
theano,
) )
from theano.gof.fg import FunctionGraph from theano.gof.type import Type
from theano.tensor.type_other import MakeSlice, SliceConstant, slicetype
from theano.tensor.subtensor import AdvancedSubtensor
from theano.tensor.opt import constant_folding from theano.tensor.opt import constant_folding
from theano.tensor.subtensor import AdvancedSubtensor
from theano.tensor.type_other import MakeSlice, SliceConstant, slicetype
def is_variable(x): def is_variable(x):
......
import pytest import pytest
from theano.gof.optdb import opt, DB from theano.gof.optdb import DB, opt
class TestDB: class TestDB:
......
import pytest
import numpy as np import numpy as np
import pytest
import theano import theano
from tests import unittest_tools as utt
from theano import tensor, Generic from theano import Generic, tensor
from theano.gof import Apply, COp, EnumList, Op, Params, ParamsType
from theano.scalar import Scalar from theano.scalar import Scalar
from theano.tensor import TensorType from theano.tensor import TensorType
from theano.gof import ParamsType, Params, EnumList, Op, COp, Apply
from tests import unittest_tools as utt
tensor_type_0d = TensorType("float64", tuple()) tensor_type_0d = TensorType("float64", tuple())
scalar_type = Scalar("float64") scalar_type = Scalar("float64")
......
from theano import tensor
from theano.compat import cmp
from theano.gof.graph import io_toposort
from theano.gof.sched import ( from theano.gof.sched import (
make_dependence_cmp,
sort_apply_nodes,
reverse_dict,
_toposort, _toposort,
make_dependence_cmp,
posort, posort,
reverse_dict,
sort_apply_nodes,
) )
from theano import tensor
from theano.gof.graph import io_toposort
from theano.compat import cmp
def test_dependence(): def test_dependence():
dependence = make_dependence_cmp() dependence = make_dependence_cmp()
......
from theano import tensor from theano import tensor
from theano.gof.graph import Variable, Apply
from theano.gof.type import Type
from theano.gof.op import Op
from theano.gof.fg import FunctionGraph from theano.gof.fg import FunctionGraph
from theano.gof.graph import Apply, Variable
from theano.gof.op import Op
from theano.gof.toolbox import NodeFinder, is_same_graph from theano.gof.toolbox import NodeFinder, is_same_graph
from theano.gof.type import Type
class TestNodeFinder: class TestNodeFinder:
......
import os import os
import numpy as np import numpy as np
import pytest import pytest
import theano import theano
from theano import Op, Apply, scalar from theano import Apply, Op, scalar
from theano.gof.type import CDataType, CEnumType, EnumList, EnumType
from theano.tensor import TensorType from theano.tensor import TensorType
from theano.gof.type import CDataType, EnumType, EnumList, CEnumType
# todo: test generic # todo: test generic
......
...@@ -2,15 +2,13 @@ import gc ...@@ -2,15 +2,13 @@ import gc
import sys import sys
import time import time
import pytest
import numpy as np import numpy as np
import pytest
import theano import theano
from theano import function, tensor from theano import function, tensor
from theano.gof import vm, OpWiseCLinker
from theano.compile import Mode from theano.compile import Mode
from theano.gof import OpWiseCLinker, vm
from theano.ifelse import ifelse from theano.ifelse import ifelse
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论