Skip to content

Commit 02eb626

Browse files
Merge pull request CamDavidsonPilon#186 from eli-b/chap1-style
autopep8 --ignore=E501,E703 fixes.
2 parents 1e55d2d + 9a62ea2 commit 02eb626

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Chapter1_Introduction/Chapter1_Introduction.ipynb

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@
194194
"\n",
195195
"# For the already prepared, I'm using Binomial's conj. prior.\n",
196196
"for k, N in enumerate(n_trials):\n",
197-
" sx = plt.subplot(len(n_trials)/2, 2, k+1)\n",
197+
" sx = plt.subplot(len(n_trials) / 2, 2, k + 1)\n",
198198
" plt.xlabel(\"$p$, probability of heads\") \\\n",
199-
" if k in [0, len(n_trials)-1] else None\n",
199+
" if k in [0, len(n_trials) - 1] else None\n",
200200
" plt.setp(sx.get_yticklabels(), visible=False)\n",
201201
" heads = data[:N].sum()\n",
202202
" y = dist.pdf(x, 1 + heads, 1 + N - heads)\n",
@@ -286,9 +286,9 @@
286286
"input": [
287287
"figsize(12.5, 4)\n",
288288
"p = np.linspace(0, 1, 50)\n",
289-
"plt.plot(p, 2*p/(1+p), color=\"#348ABD\", lw=3)\n",
290-
"#plt.fill_between(p, 2*p/(1+p), alpha=.5, facecolor=[\"#A60628\"])\n",
291-
"plt.scatter(0.2, 2*(0.2)/1.2, s=140, c=\"#348ABD\")\n",
289+
"plt.plot(p, 2 * p / (1 + p), color=\"#348ABD\", lw=3)\n",
290+
"# plt.fill_between(p, 2*p/(1+p), alpha=.5, facecolor=[\"#A60628\"])\n",
291+
"plt.scatter(0.2, 2 * (0.2) / 1.2, s=140, c=\"#348ABD\")\n",
292292
"plt.xlim(0, 1)\n",
293293
"plt.ylim(0, 1)\n",
294294
"plt.xlabel(\"Prior, $P(A) = p$\")\n",
@@ -336,12 +336,12 @@
336336
"colours = [\"#348ABD\", \"#A60628\"]\n",
337337
"\n",
338338
"prior = [0.20, 0.80]\n",
339-
"posterior = [1./3, 2./3]\n",
339+
"posterior = [1. / 3, 2. / 3]\n",
340340
"plt.bar([0, .7], prior, alpha=0.70, width=0.25,\n",
341341
" color=colours[0], label=\"prior distribution\",\n",
342342
" lw=\"3\", edgecolor=colours[0])\n",
343343
"\n",
344-
"plt.bar([0+0.25, .7+0.25], posterior, alpha=0.7,\n",
344+
"plt.bar([0 + 0.25, .7 + 0.25], posterior, alpha=0.7,\n",
345345
" width=0.25, color=colours[1],\n",
346346
" label=\"posterior distribution\",\n",
347347
" lw=\"3\", edgecolor=colours[1])\n",
@@ -491,14 +491,14 @@
491491
"lambda_ = [0.5, 1]\n",
492492
"\n",
493493
"for l, c in zip(lambda_, colours):\n",
494-
" plt.plot(a, expo.pdf(a, scale=1./l), lw=3,\n",
494+
" plt.plot(a, expo.pdf(a, scale=1. / l), lw=3,\n",
495495
" color=c, label=\"$\\lambda = %.1f$\" % l)\n",
496-
" plt.fill_between(a, expo.pdf(a, scale=1./l), color=c, alpha=.33)\n",
496+
" plt.fill_between(a, expo.pdf(a, scale=1. / l), color=c, alpha=.33)\n",
497497
"\n",
498498
"plt.legend()\n",
499499
"plt.ylabel(\"PDF at $z$\")\n",
500500
"plt.xlabel(\"$z$\")\n",
501-
"plt.ylim(0,1.2)\n",
501+
"plt.ylim(0, 1.2)\n",
502502
"plt.title(\"Probability density function of an Exponential random variable;\\\n",
503503
" differing $\\lambda$\");"
504504
],
@@ -642,7 +642,7 @@
642642
"input": [
643643
"import pymc as pm\n",
644644
"\n",
645-
"alpha = 1.0/count_data.mean() # Recall count_data is the\n",
645+
"alpha = 1.0 / count_data.mean() # Recall count_data is the\n",
646646
" # variable that holds our txt counts\n",
647647
"lambda_1 = pm.Exponential(\"lambda_1\", alpha)\n",
648648
"lambda_2 = pm.Exponential(\"lambda_2\", alpha)\n",
@@ -731,7 +731,7 @@
731731
"cell_type": "code",
732732
"collapsed": false,
733733
"input": [
734-
"### Mysterious code to be explained in Chapter 3.\n",
734+
"# Mysterious code to be explained in Chapter 3.\n",
735735
"mcmc = pm.MCMC(model)\n",
736736
"mcmc.sample(40000, 10000, 1)"
737737
],
@@ -774,7 +774,7 @@
774774
"collapsed": false,
775775
"input": [
776776
"figsize(12.5, 10)\n",
777-
"#histogram of the samples:\n",
777+
"# histogram of the samples:\n",
778778
"\n",
779779
"ax = plt.subplot(311)\n",
780780
"ax.set_autoscaley_on(False)\n",
@@ -804,7 +804,7 @@
804804
"\n",
805805
"plt.legend(loc=\"upper left\")\n",
806806
"plt.ylim([0, .75])\n",
807-
"plt.xlim([35, len(count_data)-20])\n",
807+
"plt.xlim([35, len(count_data) - 20])\n",
808808
"plt.xlabel(r\"$\\tau$ (in days)\")\n",
809809
"plt.ylabel(\"probability\");"
810810
],
@@ -923,7 +923,7 @@
923923
"cell_type": "code",
924924
"collapsed": false,
925925
"input": [
926-
"#type your code here."
926+
"# type your code here."
927927
],
928928
"language": "python",
929929
"metadata": {},
@@ -941,7 +941,7 @@
941941
"cell_type": "code",
942942
"collapsed": false,
943943
"input": [
944-
"#type your code here."
944+
"# type your code here."
945945
],
946946
"language": "python",
947947
"metadata": {},
@@ -959,7 +959,7 @@
959959
"cell_type": "code",
960960
"collapsed": false,
961961
"input": [
962-
"#type your code here."
962+
"# type your code here."
963963
],
964964
"language": "python",
965965
"metadata": {},
@@ -987,6 +987,8 @@
987987
"collapsed": false,
988988
"input": [
989989
"from IPython.core.display import HTML\n",
990+
"\n",
991+
"\n",
990992
"def css_styling():\n",
991993
" styles = open(\"../styles/custom.css\", \"r\").read()\n",
992994
" return HTML(styles)\n",

0 commit comments

Comments
 (0)