[Numpy-discussion] specifying array sizes in random vs. ones, zeros, etc

Michael Friedlander mpf@cs.ubc...
Thu Nov 11 08:44:45 CST 2010


I'm a hopeful Matlab refugee trying to understand the numpy way.
Perhaps someone can explain why some  numpy functions require
shape specifications in different ways. For example,  below I create
a random 2-by-3 array, and then a "ones" 2-by-3 array:

A = numpy.random.randn(2,3)
B = numpy.ones((2,3))

The first call takes 2 arguments; the 2nd takes a single tuple argument.
This strikes me as inconsistent, but probably I'm not grokking some
numpy subleties. Can someone please explain?




More information about the NumPy-Discussion mailing list