Python numba.jit types
Question: I have been trying to deduce how the types are set from the numba
documentation all day. I have gotten a bit of the way, but now I want to make
a function which returns a one-dimensional array, and a two-dimensjonal array,
and take a bunch of args, and I struggle to get any further:

    
    
    @jit
    class name(object)
        @double[:,:], double[:](double[:], double, double, int64)
        def solve(self, u0, a, b, n):
            self.t = linspace(a, b, n+1)
            dt = abs((b-a)/float(n))
            u = zeros(n+1, len([u0]))
            u[0] = u0
            u = advance(u, t, n, dt)
            return u.transpose(), t.transpose()   
    

The above throws these exceptions:

    
    
    Traceback (most recent call last):
      File "/home/marius/dev/python/inf1100/test_ODE.py", line 2, in <module>
        from DE import *
      File "/home/marius/dev/python/inf1100/DE.py", line 13
        @double[:,:], double[:](double[:], double, double, int64)
               ^
    SyntaxError: invalid syntax
    

It would be good if you could tell me what is going wrong, however it would be
even better if you could recommend a document which rigorously explains these
syntaxes once and for all.

Thank you for your time.

Kind regards, Marius


Answer: Here is a simpler version of a method that returns a tuple. This works for me
using Numba 0.11.1 on OS X:

    
    
    import numba
    import numpy as np
    
    @numba.jit
    class name(object):
        @numba.object_(numba.double[:], numba.double)
        def solve(self, x, a):
            y = np.empty(x.shape[0], dtype=np.float64)
            z = np.empty(x.shape[0], dtype=np.float64)
            for k in xrange(x.shape[0]):
                y[k] = x[k] * a
                z[k] = x[k] + a
    
            return y, z 
    

Then using it:

    
    
    C = name()
    a, b = C.solve(np.arange(5, dtype=np.float64), 3.0)
    

Where `a` and `b` are:

    
    
    In [24]: a
    Out[24]:
    array([  0.,   3.,   6.,   9.,  12.])
    In [22]: b
    Out[22]:
    array([ 3.,  4.,  5.,  6.,  7.])
    

