[Numpy-discussion] RandArray initialization and docs

Clay Spence cspence at sarnoff.com
Thu Apr 12 10:13:11 CDT 2001


I have occasionally dabbled with numpy in the past, but I'm starting to
use it more heavily now.  I have two (minor, I think) question/comments:

1) RandomArray seems to be initialized from the time.  At least when I
repeatedly execute a script that uses RandomArray.uniform, the first
number generated changes very little from one invocation to another.
For example, with the following file:

# testRA.py
from RandomArray import *
print uniform(-1.0, 1.0)

I get:

cholla 192% python testRA.py
cholla 193% python testRA.py
cholla 194% python testRA.py
cholla 195% python testRA.py

Is that really desirable behavior?  It is easily fixed in my script; I
just generate one random number first and throw it away.  (I'm running
on a sparc under solaris 2.6.)

2) The example in the documentation on negative strides in slices is
incorrect, or old.  It says:
>>> a = reshape(arrayrange(9),(3,3))
>>> print a[2:-1, 0]
[6 3 0]

That's not the result I get.  I think two colons were wanted there.


More information about the Numpy-discussion mailing list