提交 5684663b authored 作者: Iban Harlouchet's avatar Iban Harlouchet

One more test + some doc

上级 fb891477
......@@ -1643,6 +1643,16 @@ Linear Algebra
:note: See :func:`tensordot` and :func:`batched_dot` for
supplementary documentation.
.. class:: _nd_grid(object)
Create a dense n-dimensional 'meshgrid' with equally spaced points.
Used to create the instance ''mgrid'' and ''ogrid'' which act similarly
to their numpy equivalents.
:param sparse: boolean, optional, default=True. Specifying False leads to
the equivalent of numpy's mgrid functionality. Specifying
True leads to the equivalent of ogrid.
Gradient / Differentiation
......
......@@ -4644,7 +4644,7 @@ class _nd_grid(object):
raise NotImplementedError("Not implemented for slices "
"whose step is complex")
ranges = [arange(sl.start or 0,
sl.stop or None,
sl.stop,
sl.step or 1) for sl in args[0]]
shapes = [tuple([1] * j + [r.shape[0]] + [1] * (ndim - 1 - j))
for j, r in enumerate(ranges)]
......
......@@ -5516,6 +5516,20 @@ class TestNdGrid(unittest.TestCase):
for ng, tg in zip(n, t):
assert_array_equal(ng, tg)
def test_ogrid_theano_variable_numpy_equiv(self):
nfogrid = numpy.ogrid[0:1:.1, 1:10:1., 10:100:10.]
niogrid = numpy.ogrid[0:2:1, 1:10:1, 10:100:10]
i,j,k = dscalars('i','j','k')
l,m,n = iscalars('l','m','n')
tfogrid = ogrid[i:1:.1, 1:j:1., 10:100:k]
tiogrid = ogrid[l:2:1, 1:m:1, 10:100:n]
ff = theano.function([i, j, k], tfogrid)
fi = theano.function([l, m, n], tiogrid)
for n, t in zip((nfogrid,niogrid), (ff(0, 10, 10.),fi(0, 10, 10))):
for ng, tg in zip(n, t):
assert_array_equal(ng, tg)
class TestInversePermutation(unittest.TestCase):
def setUp(self):
utt.seed_rng()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论