//  [python]
def test_infer_shape(self):
        start, stop, step = iscalars('start', 'stop', 'step')
        out = arange(start, stop, step)
        mode = theano.config.mode
        if mode == 'FAST_COMPILE':
            mode = 'FAST_RUN'
        mode = compile.mode.get_mode(mode).excluding('fusion')
        f = function([start, stop, step], out.shape, mode=mode)
        assert len(f.maker.fgraph.toposort()) == 9

        if config.cast_policy == 'custom':
            assert out.dtype == 'int64'
        elif config.cast_policy in ('numpy', 'numpy+floatX'):
            numpy_dtype = numpy.arange(numpy.array(0, dtype=start.dtype),
                                       numpy.array(1, dtype=stop.dtype),
                                       numpy.array(1, dtype=step.dtype)).dtype
            assert out.dtype == numpy_dtype
        else:
            raise NotImplementedError(config.cast_policy)

        assert n.all(f(0, 5, 1) == len(numpy.arange(0, 5, 1)))
        assert n.all(f(2, 11, 4) == len(numpy.arange(2, 11, 4)))
        assert n.all(f(-5, 1, 1) == len(numpy.arange(-5, 1, 1)))
        assert n.all(f(10, 2, -2) == len(numpy.arange(10, 2, -2)))
        assert n.all(f(10, 2, 2) == len(numpy.arange(10, 2, 2)))
        assert n.all(f(0, 0, 1) == len(numpy.arange(0, 0, 1)))

        out = arange(start, stop, 1)
        f = function([start, stop], out.shape, mode=mode)
        assert len(f.maker.fgraph.toposort()) == 5
# 4 [Elemwise{sub,no_inplace}(stop, start), Elemwise{Cast{int64}}(Elemwise{sub,no_inplace}.0), Elemwise{Maximum{output_types_preference=transfer_type{0}}}[(0, 0)](Elemwise{Cast{int64}}.0, 0), MakeVector(Elemwise{Maximum{output_types_preference=transfer_type{0}}}[(0, 0)].0)]
        if config.cast_policy == 'custom':
            assert out.dtype == 'int64'
        elif config.cast_policy in ('numpy', 'numpy+floatX'):
            assert out.dtype == numpy.arange(
                    numpy.int32(0), numpy.int32(1), numpy.int32(1)).dtype
        else:
            raise NotImplementedError(config.cast_policy)
        assert n.all(f(0, 5) == len(numpy.arange(0, 5)))
        assert n.all(f(2, 11) == len(numpy.arange(2, 11)))
        assert n.all(f(-5, 1) == len(numpy.arange(-5, 1)))
        assert n.all(f(10, 2) == len(numpy.arange(10, 2)))
        assert n.all(f(10, 2) == len(numpy.arange(10, 2)))
        assert n.all(f(0, 0) == len(numpy.arange(0, 0)))
        assert n.all(f(-64, 64) == len(numpy.arange(-64, 64)))
        assert arange(-64, 64).shape.eval() == [128]
        assert arange(-64, 64, 2).shape.eval() == [64]

        out = arange(0, stop, 1)
        f = function([stop], out.shape, mode=mode)
        assert len(f.maker.fgraph.toposort()) == 2
        #[Elemwise{Cast{int64}}(stop), MakeVector(Elemwise{Cast{int64}}.0)]

        if config.cast_policy == 'custom':
            assert out.dtype == 'int64'
        elif config.cast_policy in ('numpy', 'numpy+floatX'):
            numpy_dtype = numpy.arange(0,
                                       numpy.array(1, dtype=stop.dtype),
                                       1).dtype
            assert out.dtype == numpy_dtype
        else:
            raise NotImplementedError(config.cast_policy)

        assert n.all(f(5) == len(numpy.arange(0, 5)))
        assert n.all(f(11) == len(numpy.arange(0, 11)))
        assert n.all(f(1) == len(numpy.arange(0, 1)))
        assert n.all(f(2) == len(numpy.arange(0, 2)))
        assert n.all(f(2) == len(numpy.arange(0, 2)))
        assert n.all(f(0) == len(numpy.arange(0, 0)))