提交 fb891477 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

Test with indices being Theano variables + tests merging

上级 1b213675
...@@ -5490,8 +5490,8 @@ class TestNdGrid(unittest.TestCase): ...@@ -5490,8 +5490,8 @@ class TestNdGrid(unittest.TestCase):
numpy.mgrid[0:2:1, 1:10:1, 10:100:10]) numpy.mgrid[0:2:1, 1:10:1, 10:100:10])
tmgrid = (mgrid[0:1:.1, 1:10:1., 10:100:10.], tmgrid = (mgrid[0:1:.1, 1:10:1., 10:100:10.],
mgrid[0:2:1, 1:10:1, 10:100:10]) mgrid[0:2:1, 1:10:1, 10:100:10])
for n, g in zip(nmgrid, tmgrid): for n, t in zip(nmgrid, tmgrid):
for ng, tg in zip(n, g): for ng, tg in zip(n, t):
assert_array_equal(ng, tg.eval()) assert_array_equal(ng, tg.eval())
def test_ogrid_numpy_equiv(self): def test_ogrid_numpy_equiv(self):
...@@ -5499,30 +5499,23 @@ class TestNdGrid(unittest.TestCase): ...@@ -5499,30 +5499,23 @@ class TestNdGrid(unittest.TestCase):
numpy.ogrid[0:2:1, 1:10:1, 10:100:10]) numpy.ogrid[0:2:1, 1:10:1, 10:100:10])
togrid = (ogrid[0:1:.1, 1:10:1., 10:100:10.], togrid = (ogrid[0:1:.1, 1:10:1., 10:100:10.],
ogrid[0:2:1, 1:10:1, 10:100:10]) ogrid[0:2:1, 1:10:1, 10:100:10])
for n, g in zip(nogrid, togrid): for n, t in zip(nogrid, togrid):
for ng, tg in zip(n, g): for ng, tg in zip(n, t):
assert_array_equal(ng, tg.eval()) assert_array_equal(ng, tg.eval())
def test_mgrid_theano_variable_numpy_equiv_float(self): def test_mgrid_theano_variable_numpy_equiv(self):
nfmgrid = numpy.mgrid[0:1:.1, 1:10:1., 10:100:10.] nfmgrid = numpy.mgrid[0:1:.1, 1:10:1., 10:100:10.]
nimgrid = numpy.mgrid[0:2:1, 1:10:1, 10:100:10]
i,j,k = dscalars('i','j','k') i,j,k = dscalars('i','j','k')
l,m,n = iscalars('l','m','n')
tfmgrid = mgrid[i:1:.1, 1:j:1., 10:100:k] tfmgrid = mgrid[i:1:.1, 1:j:1., 10:100:k]
f = theano.function([i,j,k], tfmgrid) timgrid = mgrid[l:2:1, 1:m:1, 10:100:n]
for ng, tg in zip(nfmgrid, f(0,10,10.)): ff = theano.function([i, j, k], tfmgrid)
fi = theano.function([l, m, n], timgrid)
for n, t in zip((nfmgrid,nimgrid), (ff(0, 10, 10.),fi(0, 10, 10))):
for ng, tg in zip(n, t):
assert_array_equal(ng, tg) assert_array_equal(ng, tg)
def test_mgrid_theano_variable_numpy_equiv_int(self):
nimgrid = numpy.mgrid[0:2:1, 1:10:1, 10:100:10]
i,j,k = iscalars('i','j','k')
timgrid = mgrid[i:2:1, 1:j:1, 10:100:k]
f = theano.function([i,j,k], timgrid)
for ng, tg in zip(nimgrid, f(0,10,10)):
assert_array_equal(ng, tg)
# def test_mgrid_theano_variable_numpy_equiv(self):
# nmgrid = (numpy.mgrid[0:1:.1, 1:10:1., 10:100:10.],
# numpy.mgrid[0:2:1, 1:10:1, 10:100:10])
class TestInversePermutation(unittest.TestCase): class TestInversePermutation(unittest.TestCase):
def setUp(self): def setUp(self):
utt.seed_rng() utt.seed_rng()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论