[Numpy-discussion] RandArray initialization and docs

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


Hi,

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
0.434084415436
cholla 193% python testRA.py
0.433970689774
cholla 194% python testRA.py
0.433856964111
cholla 195% python testRA.py
0.433781266212
--------

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.

Clay






More information about the NumPy-Discussion mailing list