[Numpy-discussion] c-api return two arrays

Peter numpy-discussion at maubp.freeserve.co.uk
Fri Jul 29 05:50:17 EDT 2011


On Fri, Jul 29, 2011 at 9:52 AM, Yoshi Rokuko <yoshi at rokuko.net> wrote:
>
> hey, i have an algorithm that computes two matrices like that:
>
> A(i,k) = (x(i,k) + y(i,k))/norm
> B(i,k) = (x(i,k) - y(i,k))/norm
>
> it would be convenient to have the method like that:
>
>>>> A, B = mod.meth(C, prob=.95)
>
> is ith possible to return two arrays?
>
> best regards

Yes, return a tuple of two elements. e.g.

def make_range(center, spread):
   return center-spread, center+spread

low, high = make_range(5,1)
assert low == 4
assert high == 6


Peter



More information about the NumPy-Discussion mailing list