[SciPy-user] Pros and Cons of Python verses other array environments

Bill Baxter wbaxter at gmail.com
Fri Sep 29 03:26:22 CDT 2006


On 9/29/06, Otto Tronarp <otto at tronarp.se> wrote:
> This touches the subject of inconsistency with math.add as one
> example. One of my "favorite" peeve's is how the size (shape) is given
> to functions that generate matrices. In some functions the size is
> given as a tuple, in other the size in different dimensions are given
> as seperate arguments. Here are some examples:
>
> To to create an array with shape M, N you do:
> zeros((M, N))
> ones((M, N))
> rand(M, N)
> eye(M, N)
>
> I'm sure more examples exists.

Yep,
    repmat(A,M,N)
is another one.
http://projects.scipy.org/scipy/numpy/ticket/292

But I think you'll find that rand at least is no longer there.
Instead you're supposed to use random.random((M,N))

eye(M,N) is considered to be ok, because 1-D eye is pretty useless,
and it's not clear what you'd want out of N-D identity matrix.

There has been a lot of discussion about trying to unify on shape args
always being tuples.

--bb


More information about the SciPy-user mailing list