Skip to content

Commit 456a830

Browse files
committed
Merge pull request luispedro#17 from ao-song/master
format gen_webstats.py in ch01
2 parents c714303 + b97a0be commit 456a830

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

‎ch01/gen_webstats.py‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,22 @@
1717

1818
sp.random.seed(3) # to reproduce the data later on
1919

20-
x=sp.arange(1, 31*24)
21-
y=sp.array(200*(sp.sin(2*sp.pi*x/ (7*24))), dtype=int)
20+
x=sp.arange(1, 31*24)
21+
y=sp.array(200*(sp.sin(2*sp.pi*x/(7*24))), dtype=int)
2222
y+=gamma.rvs(15, loc=0, scale=100, size=len(x))
23-
y+=2*sp.exp(x/100.0)
24-
y=sp.ma.array(y, mask=[y<0])
25-
print(sum(y), sum(y<0))
23+
y+=2*sp.exp(x/100.0)
24+
y=sp.ma.array(y, mask=[y<0])
25+
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*24forwin [0, 1, 2, 3, 4]], ['week %i'% (w+1) forwin
32-
[0, 1, 2, 3, 4]])
33-
31+
plt.xticks([w*7*24forwinrange(5)],
32+
['week %i'%(w+1) forwinrange(5)])
3433
plt.autoscale(tight=True)
3534
plt.grid()
3635
plt.savefig(os.path.join(CHART_DIR, "1400_01_01.png"))
3736

38-
# sp.savetxt(os.path.join("..", "web_traffic.tsv"),
39-
# zip(x[~y.mask],y[~y.mask]), delimiter="\t", fmt="%i")
40-
41-
sp.savetxt(os.path.join(
42-
DATA_DIR, "web_traffic.tsv"), list(zip(x, y)), delimiter="\t", fmt="%s")
37+
sp.savetxt(os.path.join(DATA_DIR, "web_traffic.tsv"),
38+
list(zip(x, y)), delimiter="\t", fmt="%s")

0 commit comments

Comments
(0)