From 57cc9ac52b0faa3b757021a2cafffebda991981c Mon Sep 17 00:00:00 2001 From: Dan Lopez Date: Tue, 24 May 2016 22:30:42 -0700 Subject: [PATCH] gen_webstats error fix --- ch01/gen_webstats.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ch01/gen_webstats.py b/ch01/gen_webstats.py index 61d0b738..a519c5cc 100644 --- a/ch01/gen_webstats.py +++ b/ch01/gen_webstats.py @@ -15,12 +15,12 @@ from utils import DATA_DIR, CHART_DIR -sp.random.seed(3) # to reproduce the data later on +sp.random.seed(5) # to reproduce the data later on x = sp.arange(1, 31*24) y = sp.array(200*(sp.sin(2*sp.pi*x/(7*24))), dtype=int) -y += gamma.rvs(15, loc=0, scale=100, size=len(x)) -y += 2 * sp.exp(x/100.0) +y += gamma.rvs(15, loc=0, scale=100, size=len(x)).astype('int64') +y += 2 * sp.exp(x/100.0).astype('int64') y = sp.ma.array(y, mask=[y<0]) print(sum(y), sum(y<0)) @@ -28,11 +28,11 @@ plt.title("Web traffic over the last month") plt.xlabel("Time") plt.ylabel("Hits/hour") -plt.xticks([w*7*24 for w in range(5)], +plt.xticks([w*7*24 for w in range(5)], ['week %i' %(w+1) for w in range(5)]) plt.autoscale(tight=True) plt.grid() plt.savefig(os.path.join(CHART_DIR, "1400_01_01.png")) -sp.savetxt(os.path.join(DATA_DIR, "web_traffic.tsv"), +sp.savetxt(os.path.join(DATA_DIR, "web_traffic.tsv"), list(zip(x, y)), delimiter="\t", fmt="%s")