[Matrix-SIG] NumPy installation directory
Rob Managan
managan@llnl.gov
Wed, 13 Jan 1999 11:22:33 -0800
AS I tested the latest LLNL release on the Mac I ran up against an old bug
that seems to have never been satisfactorily fixed. The problem is in
RandomArray.py. When the seed is set using the time you find that on the
Mac that the current time is greater than an int can hold. This is because
time is measured from Jan 1, 1904. The second issue is that on the Mac the
tim eis an integer and has no fraction al part so the second seed was
always zero. Here is one attempt at a fix. This is the top part of
RandomArray.py The goal was to split the time into two roughly equal parts.
import ranlib
import Numeric
import sys
import math
from types import *
ArgumentError = "ArgumentError"
def seed(x=0,y=0):
if type (x) != IntType or type (y) != IntType :
raise ArgumentError, "seed requires integer arguments."
if x == y == 0:
import time
t = time.time()
if sys.platform == 'mac' :
ndigits = int(math.log10(t))
base = 10**(ndigits/2)
x = int(t/base)
y = int(t%base)
else:
x = int(t)
y = int((t-int(t))*1000000)
ranlib.set_seeds(x,y)
return
Comments are appreciated.
*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-
Rob Managan mailto://managan@llnl.gov
LLNL ph: 925-423-0903
P.O. Box 808, L-098 FAX: 925-423-5804
Livermore, CA 94551-0808