[SciPy-user] Inconsistent function calls?
Stéfan van der Walt
stefan at sun.ac.za
Thu May 21 11:48:21 EDT 2009
Hi Ivo
2009/5/21 Ivo Maljevic <ivo.maljevic at gmail.com>:
> If you want to generate a random number matrix, you can make the same call
> as with matlab:
>
> rand(2,2) for 2x2 matrix,
> randn(1,5) for 1x5 etc.
>
> but if you want to generate ones or zeros matrices, you cannot say
> ones(3,3), you have to write ones([3,3]) or zeros([3,3]) (note the extra
> brackets).
This is one of those situations where you have six on the one hand and
half-a-dozen on the other.
ones(3, 3) implies that the code
shape = (3, 4)
ones(shape)
has to be changed to
ones(*shape)
Also, it becomes harder to understand the function signatures:
def ones(shape) -> def ones(*args)
which means that it is no longer clear what the function expects as parameters.
We have decided to use func(shape) as the standard interface, so you
may see randn and rand as exceptions.
Regards
Stéfan
More information about the SciPy-User
mailing list