Quoting Bill Baxter <wbaxter@gmail.com>:
On 9/29/06, Otto Tronarp <otto@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.
That is valid point, but I would still argue for unified use of shape args. Assume that I have a function that does some calculations on a matrix and adds another like this: def foo(A, mxCreateFunc): # do some stuff with A return A + mxCreateFunc(A.shape) If we hade unified shape args I could do foo(A, random) # Add some noice foo(A, zeros # Don't add nocie foo(A, eye) # ?? I must admitt that I don't have any real world use cases for eye at hand, but I'm sure they are out there... Otto
There has been a lot of discussion about trying to unify on shape args always being tuples.
--bb _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user