Skip to content

Commit 2996d38

Browse files
authored
Add click install to fix ci (#193)
* Add black
1 parent e0767fa commit 2996d38

13 files changed

+38
-38
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
rev: 0.5.6
99
hooks:
1010
- id: nbqa-black
11-
additional_dependencies: [black==20.8b1]
11+
additional_dependencies: [black==22.3.0]
1212
files: ^(Rethinking_2|BSM)/
1313
- id: nbqa-isort
1414
additional_dependencies: [isort==5.6.4]

BSM/Chapter_03_00_Bayesian_CLT.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
" A = Y - 0.5\n",
5555
" B = n - Y - 0.5\n",
5656
" θ_MAP = A / (A + B)\n",
57-
" info = A / θ_MAP ** 2 + B / (1 - θ_MAP) ** 2\n",
57+
" info = A / θ_MAP**2 + B / (1 - θ_MAP) ** 2\n",
5858
"\n",
5959
" post1 = stats.binom(n, θ).pmf(Y) * stats.beta(0.5, 0.5).pdf(θ)\n",
6060
" post1 = post1 / np.sum(post1)\n",

BSM/Chapter_03_01_Gibbs_sampling_one_sample_t-test.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
" # sample mu|s2,Y\n",
143143
" MN = np.sum(Y) / (n + m)\n",
144144
" VR = s2 / (n + m)\n",
145-
" mu = stats.norm(MN, VR ** 0.5).rvs(1)\n",
145+
" mu = stats.norm(MN, VR**0.5).rvs(1)\n",
146146
"\n",
147147
" # sample s2|mu,Y\n",
148148
" A = a + n / 2\n",
@@ -291,7 +291,7 @@
291291
}
292292
],
293293
"source": [
294-
"keep_s = keep_s2 ** 0.5\n",
294+
"keep_s = keep_s2**0.5\n",
295295
"plt.hist(keep_s2)\n",
296296
"plt.xlabel(\"sigma\")\n",
297297
"plt.title(\"Marginal posterior\");"

BSM/Chapter_03_02_Gibbs_sampling_two_sample_t-test.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@
122122
" # sample muY|muZ,s2,Y,Z\n",
123123
" A = np.sum(Y) / s2 + mu_0 / s2_0\n",
124124
" B = n / s2 + 1 / s2_0\n",
125-
" muY = stats.norm(A / B, 1 / B ** 0.5).rvs(1)[0]\n",
125+
" muY = stats.norm(A / B, 1 / B**0.5).rvs(1)[0]\n",
126126
"\n",
127127
" # sample muZ|muY,s2,Y,Z\n",
128128
" A = np.sum(Z) / s2 + mu_0 / s2_0\n",
129129
" B = m / s2 + 1 / s2_0\n",
130-
" muZ = stats.norm(A / B, 1 / B ** 0.5).rvs(1)[0]\n",
130+
" muZ = stats.norm(A / B, 1 / B**0.5).rvs(1)[0]\n",
131131
"\n",
132132
" # sample s2|muY,muZ,Y,Z\n",
133133
" A = n / 2 + m / 2 + a\n",

BSM/Chapter_03_03_Gibbs_sampling_for_simple_linear_regression.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,12 @@
394394
" # sample alpha\n",
395395
" V = n / s2 + mu_0 / s2_0\n",
396396
" M = np.sum(Y - X * β) / s2 + 1 / s2_0\n",
397-
" α = stats.norm(M / V, 1 / V ** 0.5).rvs(1)[0]\n",
397+
" α = stats.norm(M / V, 1 / V**0.5).rvs(1)[0]\n",
398398
"\n",
399399
" # sample beta\n",
400-
" V = np.sum(X ** 2) / s2 + mu_0 / s2_0\n",
400+
" V = np.sum(X**2) / s2 + mu_0 / s2_0\n",
401401
" M = np.sum(X * (Y - α)) / s2 + 1 / s2_0\n",
402-
" β = stats.norm(M / V, 1 / V ** 0.5).rvs(1)[0]\n",
402+
" β = stats.norm(M / V, 1 / V**0.5).rvs(1)[0]\n",
403403
"\n",
404404
" # sample s2|mu,Y,Z\n",
405405
" A = n / 2 + a\n",

BSM/Chapter_03_09_Simple_linear_regression_in_PyMC3.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"with pm.Model() as model:\n",
8080
" # Priors\n",
8181
" τ = pm.Gamma(\"τ\", 0.1, 10)\n",
82-
" σ = pm.Deterministic(\"σ\", 1 / (τ ** 0.5))\n",
82+
" σ = pm.Deterministic(\"σ\", 1 / (τ**0.5))\n",
8383
" # σ = pm.HalfNormal('σ', np.std(mass))\n",
8484
" β1 = pm.Normal(\"β1\", 0, 1000)\n",
8585
" β2 = pm.Normal(\"β2\", 0, 1000)\n",

Rethinking_2/Chp_04.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,7 @@
30623062
],
30633063
"source": [
30643064
"d[\"weight_std\"] = (d.weight - d.weight.mean()) / d.weight.std()\n",
3065-
"d[\"weight_std2\"] = d.weight_std ** 2\n",
3065+
"d[\"weight_std2\"] = d.weight_std**2\n",
30663066
"\n",
30673067
"with pm.Model() as m_4_5:\n",
30683068
" a = pm.Normal(\"a\", mu=178, sd=100)\n",
@@ -3329,7 +3329,7 @@
33293329
"metadata": {},
33303330
"outputs": [],
33313331
"source": [
3332-
"weight_m = np.vstack((d.weight_std, d.weight_std ** 2, d.weight_std ** 3))"
3332+
"weight_m = np.vstack((d.weight_std, d.weight_std**2, d.weight_std**3))"
33333333
]
33343334
},
33353335
{

Rethinking_2/Chp_06.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@
12171217
"\n",
12181218
"\n",
12191219
"def sim_coll(r=0.9):\n",
1220-
" x = np.random.normal(loc=r * d[\"perc.fat\"], scale=np.sqrt((1 - r ** 2) * np.var(d[\"perc.fat\"])))\n",
1220+
" x = np.random.normal(loc=r * d[\"perc.fat\"], scale=np.sqrt((1 - r**2) * np.var(d[\"perc.fat\"])))\n",
12211221
" _, cov = curve_fit(mv, (d[\"perc.fat\"], x), d[\"kcal.per.g\"])\n",
12221222
" return np.sqrt(np.diag(cov))[-1]\n",
12231223
"\n",

Rethinking_2/Chp_09.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
],
140140
"source": [
141141
"def rad_dist(Y):\n",
142-
" return np.sqrt(np.sum(Y ** 2))\n",
142+
" return np.sqrt(np.sum(Y**2))\n",
143143
"\n",
144144
"\n",
145145
"fig, ax = plt.subplots(1, 1, figsize=[7, 3])\n",
@@ -207,8 +207,8 @@
207207
"def calc_U_gradient(x, y, q, a=0, b=1, k=0, d=1):\n",
208208
" muy, mux = q\n",
209209
"\n",
210-
" G1 = np.sum(y - muy) + (a - muy) / b ** 2 # dU/dmuy\n",
211-
" G2 = np.sum(x - mux) + (k - mux) / b ** 2 # dU/dmux\n",
210+
" G1 = np.sum(y - muy) + (a - muy) / b**2 # dU/dmuy\n",
211+
" G2 = np.sum(x - mux) + (k - mux) / b**2 # dU/dmux\n",
212212
"\n",
213213
" return np.array([-G1, -G2])"
214214
]
@@ -257,9 +257,9 @@
257257
" p *= -1\n",
258258
" # Evaluate potential and kinetic energies sat start and end of trajectory\n",
259259
" current_U = U(x, y, current_q)\n",
260-
" current_K = np.sum(current_p ** 2) / 2\n",
260+
" current_K = np.sum(current_p**2) / 2\n",
261261
" proposed_U = U(x, y, q)\n",
262-
" proposed_K = np.sum(p ** 2) / 2\n",
262+
" proposed_K = np.sum(p**2) / 2\n",
263263
" # Accept or reject the state at end of trajectory, returning either\n",
264264
" # the position at the end of the trajectory or the initial position\n",
265265
" accept = False\n",

Rethinking_2/Chp_10.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
],
234234
"source": [
235235
"p = 0.7\n",
236-
"A = [(1 - p) ** 2, p * (1 - p), (1 - p) * p, p ** 2]\n",
236+
"A = [(1 - p) ** 2, p * (1 - p), (1 - p) * p, p**2]\n",
237237
"A"
238238
]
239239
},
@@ -299,9 +299,9 @@
299299
"metadata": {},
300300
"outputs": [],
301301
"source": [
302-
"H = np.zeros(10 ** 5)\n",
303-
"p = np.zeros((10 ** 5, 4))\n",
304-
"for rep in range(10 ** 5):\n",
302+
"H = np.zeros(10**5)\n",
303+
"p = np.zeros((10**5, 4))\n",
304+
"for rep in range(10**5):\n",
305305
" h, p_ = sim_p()\n",
306306
" H[rep] = h\n",
307307
" p[rep] = p_"

0 commit comments

Comments
 (0)