[SciPy-user] newby: why the inconsistancy between zeros and randn?

weg werp wegwerp at gmail.com
Thu May 4 17:20:22 EDT 2006


Hi group,

as a long time matlab user I am used to do
y=zeros(size(x))
y=ones(size(x))
which nicely translates into
y=zeros(shape(x))
y=ones(shape(x))

However, this does not work for rand and randn, there I have to do
y=randn(*shape(x))
because randn does not accept a shape tuple, but expects the
dimensions as separate variables. Is there any reason for this?

According to the docs, Matlab accepts both a size array or seperate
dimensions. Would it also be possible to allow both forms in Numpy? (I
guess that would violate some Zen rule, I don't know which one). If
not, I think these similar functions should have the same signature.

Cheers,
Bas




More information about the SciPy-User mailing list