[Numpy-discussion] Shapes and sizes

Sasha ndarray at mac.com
Fri Feb 24 10:45:01 CST 2006


On 2/24/06, Albert Strasheim <fullung at gmail.com> wrote:
> def outsize(n):
>     if n % 2 == 0: return n/2+1
>     return (n+1)/2
> if arra.ndim == 0:
>     b = empty(())
> elif arra.ndim == 1:
>     b = empty((outsize(arra.shape[0]),))
> else:
>     b = empty((arra.shape[0],outsize(arra.shape[1]))

Try
>>> empty(map(outsize, arra.shape))

> This problem is solved in MATLAB where there is no distinction between 1 and [1].
>
> How do you guys deal with this problem in your functions?

You might want to take a look at the parallel thread under "A case for
rank-0 arrays."




More information about the Numpy-discussion mailing list