Skip to content

Commit 57cc9ac

Browse files
committed
gen_webstats error fix
1 parent 456a830 commit 57cc9ac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ch01/gen_webstats.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515

1616
from utils import DATA_DIR, CHART_DIR
1717

18-
sp.random.seed(3) # to reproduce the data later on
18+
sp.random.seed(5) # to reproduce the data later on
1919

2020
x = sp.arange(1, 31*24)
2121
y = sp.array(200*(sp.sin(2*sp.pi*x/(7*24))), dtype=int)
22-
y += gamma.rvs(15, loc=0, scale=100, size=len(x))
23-
y += 2 * sp.exp(x/100.0)
22+
y += gamma.rvs(15, loc=0, scale=100, size=len(x)).astype('int64')
23+
y += 2 * sp.exp(x/100.0).astype('int64')
2424
y = sp.ma.array(y, mask=[y<0])
2525
print(sum(y), sum(y<0))
2626

2727
plt.scatter(x, y)
2828
plt.title("Web traffic over the last month")
2929
plt.xlabel("Time")
3030
plt.ylabel("Hits/hour")
31-
plt.xticks([w*7*24 for w in range(5)],
31+
plt.xticks([w*7*24 for w in range(5)],
3232
['week %i' %(w+1) for w in range(5)])
3333
plt.autoscale(tight=True)
3434
plt.grid()
3535
plt.savefig(os.path.join(CHART_DIR, "1400_01_01.png"))
3636

37-
sp.savetxt(os.path.join(DATA_DIR, "web_traffic.tsv"),
37+
sp.savetxt(os.path.join(DATA_DIR, "web_traffic.tsv"),
3838
list(zip(x, y)), delimiter="\t", fmt="%s")

0 commit comments

Comments
 (0)