Skip to content

Commit 4245f96

Browse files
committed
Ending code cells with a semicolon.
1 parent d295884 commit 4245f96

File tree

7 files changed

+57
-57
lines changed

7 files changed

+57
-57
lines changed

Prologue/Prologue.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"def css_styling():\n",
193193
" styles = open(\"../styles/custom.css\", \"r\").read()\n",
194194
" return HTML(styles)\n",
195-
"css_styling()\n"
195+
"css_styling();"
196196
],
197197
"language": "python",
198198
"metadata": {},
@@ -282,4 +282,4 @@
282282
"metadata": {}
283283
}
284284
]
285-
}
285+
}

sandbox/ABCtests.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"cell_type": "code",
1919
"collapsed": false,
2020
"input": [
21-
"import pymc as pm\n"
21+
"import pymc as pm;"
2222
],
2323
"language": "python",
2424
"metadata": {},
@@ -40,7 +40,7 @@
4040
" if np.array_equal(fake_obs, obs):\n",
4141
" return uni\n",
4242
" else:\n",
43-
" return None\n"
43+
" return None;"
4444
],
4545
"language": "python",
4646
"metadata": {},
@@ -51,7 +51,7 @@
5151
"cell_type": "code",
5252
"collapsed": false,
5353
"input": [
54-
"mcmc = pm.MCMC([uni, fake_obs, accept])\n"
54+
"mcmc = pm.MCMC([uni, fake_obs, accept]);"
5555
],
5656
"language": "python",
5757
"metadata": {},
@@ -62,7 +62,7 @@
6262
"cell_type": "code",
6363
"collapsed": false,
6464
"input": [
65-
"mcmc.sample(10000)\n"
65+
"mcmc.sample(10000);"
6666
],
6767
"language": "python",
6868
"metadata": {},
@@ -89,7 +89,7 @@
8989
"cell_type": "code",
9090
"collapsed": false,
9191
"input": [
92-
"samples = mcmc.trace('accept')[:]\n"
92+
"samples = mcmc.trace('accept')[:];"
9393
],
9494
"language": "python",
9595
"metadata": {},
@@ -100,7 +100,7 @@
100100
"cell_type": "code",
101101
"collapsed": false,
102102
"input": [
103-
"hist(samples[samples > 0])\n"
103+
"hist(samples[samples > 0]);"
104104
],
105105
"language": "python",
106106
"metadata": {},
@@ -127,7 +127,7 @@
127127
"cell_type": "code",
128128
"collapsed": false,
129129
"input": [
130-
"samples[:1000]\n"
130+
"samples[:1000];"
131131
],
132132
"language": "python",
133133
"metadata": {},

sandbox/Chapter10_/More hacking with PyMC.ipynb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"collapsed": false,
1313
"input": [
1414
"figsize(12.5, 4)\n",
15-
"import scipy.stats as stats\n"
15+
"import scipy.stats as stats;"
1616
],
1717
"language": "python",
1818
"metadata": {},
@@ -48,7 +48,7 @@
4848
"cell_type": "code",
4949
"collapsed": false,
5050
"input": [
51-
"run github_datapull.py\n"
51+
"run github_datapull.py;"
5252
],
5353
"language": "python",
5454
"metadata": {},
@@ -350,7 +350,7 @@
350350
"plt.title(\"Popularity of Repos (as measured by stars and forks)\")\n",
351351
"plt.xlabel(\"$K$\")\n",
352352
"plt.ylabel(\"number of repos with stars/forks $K$\")\n",
353-
"plt.xlim(-200, 35000)\n"
353+
"plt.xlim(-200, 35000);"
354354
],
355355
"language": "python",
356356
"metadata": {},
@@ -385,7 +385,7 @@
385385
"plt.legend(loc=\"upper right\")\n",
386386
"plt.title(\"Log-Log plot of Popularity of Repos (as measured by stars and forks)\")\n",
387387
"plt.xlabel(\"$\\log{K}$\")\n",
388-
"plt.ylabel(\"$\\log$(number of repos with stars/forks < K )\")\n"
388+
"plt.ylabel(\"$\\log$(number of repos with stars/forks < K )\");"
389389
],
390390
"language": "python",
391391
"metadata": {},
@@ -473,7 +473,7 @@
473473
"model = pm.Model([param, yule_simon])\n",
474474
"mcmc = pm.MCMC(model)\n",
475475
"\n",
476-
"mcmc.sample(10000, 8000)\n"
476+
"mcmc.sample(10000, 8000);"
477477
],
478478
"language": "python",
479479
"metadata": {},
@@ -501,7 +501,7 @@
501501
"def logp(value, rho):\n",
502502
" return np.log(rho) + np.log(beta(value, rho + 1))\n",
503503
"\n",
504-
"beta(repo_with_stars, 1.3)\n"
504+
"beta(repo_with_stars, 1.3);"
505505
],
506506
"language": "python",
507507
"metadata": {},
@@ -537,7 +537,7 @@
537537
"plt.plot(x, exp(-(x - 1) ** 2), label=\"Normal distribution\")\n",
538538
"plt.plot(x, x ** (-2), label=r\"Power law, $\\beta = -2$\")\n",
539539
"plt.plot(x, x ** (-1), label=r\"Power law, $\\beta = -1$\")\n",
540-
"plt.legend()\n"
540+
"plt.legend();"
541541
],
542542
"language": "python",
543543
"metadata": {},
@@ -574,7 +574,7 @@
574574
"def css_styling():\n",
575575
" styles = open(\"../styles/custom.css\", \"r\").read()\n",
576576
" return HTML(styles)\n",
577-
"css_styling()\n"
577+
"css_styling();"
578578
],
579579
"language": "python",
580580
"metadata": {},
@@ -662,7 +662,7 @@
662662
"\n",
663663
"@pm.observed\n",
664664
"def survival(value=y_, beta=beta):\n",
665-
" return np.sum([value[i - 1] * np.log((i + 0.) ** beta - (i + 1.) ** beta) for i in range(1, 99)])\n"
665+
" return np.sum([value[i - 1] * np.log((i + 0.) ** beta - (i + 1.) ** beta) for i in range(1, 99)]);"
666666
],
667667
"language": "python",
668668
"metadata": {},
@@ -678,7 +678,7 @@
678678
"# map_.fit()\n",
679679
"\n",
680680
"mcmc = pm.MCMC(model)\n",
681-
"mcmc.sample(50000, 40000)\n"
681+
"mcmc.sample(50000, 40000);"
682682
],
683683
"language": "python",
684684
"metadata": {},
@@ -706,7 +706,7 @@
706706
"collapsed": false,
707707
"input": [
708708
"from pymc.Matplot import plot as mcplot\n",
709-
"mcplot(mcmc)\n"
709+
"mcplot(mcmc);"
710710
],
711711
"language": "python",
712712
"metadata": {},
@@ -729,7 +729,7 @@
729729
"cell_type": "code",
730730
"collapsed": false,
731731
"input": [
732-
"stars_to_explore[1:]\n"
732+
"stars_to_explore[1:];"
733733
],
734734
"language": "python",
735735
"metadata": {},
@@ -749,7 +749,7 @@
749749
"cell_type": "code",
750750
"collapsed": false,
751751
"input": [
752-
"a = stats.pareto.rvs(2.5, size=(50000, 1))\n"
752+
"a = stats.pareto.rvs(2.5, size=(50000, 1));"
753753
],
754754
"language": "python",
755755
"metadata": {},
@@ -761,7 +761,7 @@
761761
"collapsed": false,
762762
"input": [
763763
"hist(a, bins=100)\n",
764-
"print\n"
764+
"print;"
765765
],
766766
"language": "python",
767767
"metadata": {},
@@ -784,7 +784,7 @@
784784
"cell_type": "code",
785785
"collapsed": false,
786786
"input": [
787-
"y = [(a >= i).sum() for i in range(1, 100)]\n"
787+
"y = [(a >= i).sum() for i in range(1, 100)];"
788788
],
789789
"language": "python",
790790
"metadata": {},
@@ -798,7 +798,7 @@
798798
"y_ = -np.diff(y)\n",
799799
"print y_\n",
800800
"\n",
801-
"print y\n"
801+
"print y;"
802802
],
803803
"language": "python",
804804
"metadata": {},
@@ -826,7 +826,7 @@
826826
"cell_type": "code",
827827
"collapsed": false,
828828
"input": [
829-
"b = -2.3\n"
829+
"b = -2.3;"
830830
],
831831
"language": "python",
832832
"metadata": {},
@@ -837,7 +837,7 @@
837837
"cell_type": "code",
838838
"collapsed": false,
839839
"input": [
840-
"np.sum([y_[i - 1] * np.log((i + 0.) ** b - (i + 1.) ** b) for i in range(1, 7)]) + y[-1] * np.log(7)\n"
840+
"np.sum([y_[i - 1] * np.log((i + 0.) ** b - (i + 1.) ** b) for i in range(1, 7)]) + y[-1] * np.log(7);"
841841
],
842842
"language": "python",
843843
"metadata": {},
@@ -856,7 +856,7 @@
856856
"cell_type": "code",
857857
"collapsed": false,
858858
"input": [
859-
"y_\n"
859+
"y_;"
860860
],
861861
"language": "python",
862862
"metadata": {},
@@ -875,7 +875,7 @@
875875
"cell_type": "code",
876876
"collapsed": false,
877877
"input": [
878-
"np.append(y_, y[-1])\n"
878+
"np.append(y_, y[-1]);"
879879
],
880880
"language": "python",
881881
"metadata": {},
@@ -894,7 +894,7 @@
894894
"cell_type": "code",
895895
"collapsed": false,
896896
"input": [
897-
"mc.Uninformative?\n"
897+
"mc.Uninformative?"
898898
],
899899
"language": "python",
900900
"metadata": {},

sandbox/CommitDataForChapter1.ipynb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"from requests import get\n",
2222
"response = get('https://api.github.com/repos/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/stats/commit_activity').json()\n",
2323
"weekly_totals = np.array(map(lambda x: x['total'], response))\n",
24-
"weekly_totals = weekly_totals[np.where(weekly_totals)[0]] # gives me 52 weeks, but project started < 1 year ago so it backwards fills with 0s\n"
24+
"weekly_totals = weekly_totals[np.where(weekly_totals)[0]] # gives me 52 weeks, but project started < 1 year ago so it backwards fills with 0s;"
2525
],
2626
"language": "python",
2727
"metadata": {},
@@ -37,7 +37,7 @@
3737
"\n",
3838
"plt.bar(range(n_count_data), weekly_totals)\n",
3939
"print weekly_totals\n",
40-
"print n_count_data\n"
40+
"print n_count_data;"
4141
],
4242
"language": "python",
4343
"metadata": {},
@@ -71,7 +71,7 @@
7171
"lambda_1 = pm.Exponential(\"lambda_1\", alpha)\n",
7272
"lambda_2 = pm.Exponential(\"lambda_2\", alpha)\n",
7373
"\n",
74-
"tau = pm.DiscreteUniform(\"tau\", lower=0, upper=n_count_data)\n"
74+
"tau = pm.DiscreteUniform(\"tau\", lower=0, upper=n_count_data);"
7575
],
7676
"language": "python",
7777
"metadata": {},
@@ -87,7 +87,7 @@
8787
" out = np.zeros(n_count_data)\n",
8888
" out[:tau] = lambda_1 # lambda before tau is lambda1\n",
8989
" out[tau:] = lambda_2 # lambda after tau is lambda2\n",
90-
" return out\n"
90+
" return out;"
9191
],
9292
"language": "python",
9393
"metadata": {},
@@ -100,7 +100,7 @@
100100
"input": [
101101
"observation = pm.Poisson(\"obs\", lambda_, value=count_data, observed=True)\n",
102102
"\n",
103-
"model = pm.Model([observation, lambda_1, lambda_2, tau])\n"
103+
"model = pm.Model([observation, lambda_1, lambda_2, tau]);"
104104
],
105105
"language": "python",
106106
"metadata": {},
@@ -113,7 +113,7 @@
113113
"input": [
114114
"# Mysterious code to be explained in Chapter 3.\n",
115115
"mcmc = pm.MCMC(model)\n",
116-
"mcmc.sample(40000, 10000, 1)\n"
116+
"mcmc.sample(40000, 10000, 1);"
117117
],
118118
"language": "python",
119119
"metadata": {},
@@ -142,7 +142,7 @@
142142
"input": [
143143
"lambda_1_samples = mcmc.trace('lambda_1')[:]\n",
144144
"lambda_2_samples = mcmc.trace('lambda_2')[:]\n",
145-
"tau_samples = mcmc.trace('tau')[:]\n"
145+
"tau_samples = mcmc.trace('tau')[:];"
146146
],
147147
"language": "python",
148148
"metadata": {},
@@ -188,7 +188,7 @@
188188
"plt.legend(loc=\"upper left\")\n",
189189
"plt.ylim([0, .75])\n",
190190
"plt.xlabel(\"$\\tau$ (in days)\")\n",
191-
"plt.ylabel(\"probability\")\n"
191+
"plt.ylabel(\"probability\");"
192192
],
193193
"language": "python",
194194
"metadata": {},
@@ -211,7 +211,7 @@
211211
"cell_type": "code",
212212
"collapsed": false,
213213
"input": [
214-
"n_count_data\n"
214+
"n_count_data;"
215215
],
216216
"language": "python",
217217
"metadata": {},
@@ -230,7 +230,7 @@
230230
"cell_type": "code",
231231
"collapsed": false,
232232
"input": [
233-
"lambda_2_samples\n"
233+
"lambda_2_samples;"
234234
],
235235
"language": "python",
236236
"metadata": {},

sandbox/GithubUsers.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"print ids[:10]\n",
3131
"print\n",
3232
"print \"Number of unique ids found: \", ids.shape[0]\n",
33-
"print \"Largest user id: \", ids.max()\n"
33+
"print \"Largest user id: \", ids.max();"
3434
],
3535
"language": "python",
3636
"metadata": {},
@@ -89,7 +89,7 @@
8989
"plt.hist(ids, bins=45, alpha=0.9)\n",
9090
"plt.title(\"Histogram of %d Github User ids\" % ids.shape[0])\n",
9191
"plt.xlabel(\"User id\")\n",
92-
"plt.ylabel(\"Frequency\")\n"
92+
"plt.ylabel(\"Frequency\");"
9393
],
9494
"language": "python",
9595
"metadata": {},
@@ -144,7 +144,7 @@
144144
"\n",
145145
"# code to be examplained in Chp. 3.\n",
146146
"mcmc = pm.MCMC([upper_bound, obs])\n",
147-
"mcmc.sample(100000, 45000)\n"
147+
"mcmc.sample(100000, 45000);"
148148
],
149149
"language": "python",
150150
"metadata": {},
@@ -187,7 +187,7 @@
187187
"plt.title(\"Posterior distribution of total number of Github users\")\n",
188188
"plt.xlabel(\"number of users (in millions)\")\n",
189189
"plt.legend()\n",
190-
"plt.xlim(ids.max() / FACTOR - 0.01, ids.max() / FACTOR + 0.12)\n"
190+
"plt.xlim(ids.max() / FACTOR - 0.01, ids.max() / FACTOR + 0.12);"
191191
],
192192
"language": "python",
193193
"metadata": {},

0 commit comments

Comments
 (0)