[Numpy-discussion] rand argument question
Sven Schreiber
svetosch at gmx.net
Fri Jun 2 10:38:46 CDT 2006
Hi all,
this may be a stupid question, but why doesn't rand accept a shape tuple
as argument? I find the difference between the argument types of rand
and (for example) zeros somewhat confusing. (See below for
illustration.) Can anybody offer an intuition/explanation?
(This is still on 0.9.6 because of matplotlib compatibility.)
Thanks much,
Sven
>>> import numpy as n
>>> n.rand((3,2))
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "mtrand.pyx", line 433, in mtrand.RandomState.rand
File "mtrand.pyx", line 361, in mtrand.RandomState.random_sample
File "mtrand.pyx", line 131, in mtrand.cont0_array
TypeError: an integer is required
>>> n.zeros((3,2))
array([[0, 0],
[0, 0],
[0, 0]])
>>> n.zeros(3,2)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: data type not understood
>>> n.rand(3,2)
array([[ 0.27017528, 0.98280906],
[ 0.58592731, 0.63706962],
[ 0.74705193, 0.65980377]])
>>>
More information about the Numpy-discussion
mailing list