Skip to content

Commit 8302572

Browse files
committed
Updated for Python 3.6
1 parent bf04f49 commit 8302572

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

02-Discrete-Bayes.ipynb

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"metadata": {},
2121
"outputs": [],
2222
"source": [
23-
"from __future__ import division, print_function\n",
2423
"%matplotlib inline"
2524
]
2625
},
@@ -36,7 +35,7 @@
3635
" <style>\n",
3736
" .output_wrapper, .output {\n",
3837
" height:auto !important;\n",
39-
" max-height:100000px; \n",
38+
" max-height:100000px;\n",
4039
" }\n",
4140
" .output_scroll {\n",
4241
" box-shadow:none !important;\n",
@@ -582,7 +581,7 @@
582581
{
583582
"data": {
584583
"application/vnd.jupyter.widget-view+json": {
585-
"model_id": "6a0f5d2b16e54121bd8a3b11957d0966",
584+
"model_id": "69e1cf784fd743ddaeae41d5fa161216",
586585
"version_major": 2,
587586
"version_minor": 0
588587
},
@@ -758,7 +757,7 @@
758757
{
759758
"data": {
760759
"application/vnd.jupyter.widget-view+json": {
761-
"model_id": "5e1bbeaf87af4835869cd7a6676fa209",
760+
"model_id": "b7f90f29b9394f82b4c64982c8eab901",
762761
"version_major": 2,
763762
"version_minor": 0
764763
},
@@ -783,7 +782,7 @@
783782
"# make interactive plot\n",
784783
"def show_prior(step):\n",
785784
" book_plots.bar_plot(predict_beliefs[step-1])\n",
786-
" plt.title('Step {}'.format(step))\n",
785+
" plt.title(f'Step {step}')\n",
787786
"\n",
788787
"interact(show_prior, step=IntSlider(value=1, max=len(predict_beliefs)));"
789788
]
@@ -1247,7 +1246,7 @@
12471246
{
12481247
"data": {
12491248
"application/vnd.jupyter.widget-view+json": {
1250-
"model_id": "9f7338d5d95a4133ae3825b18020b9cd",
1249+
"model_id": "5e52dc4ac04b4244ad4357a4fd837902",
12511250
"version_major": 2,
12521251
"version_minor": 0
12531252
},
@@ -1300,7 +1299,7 @@
13001299
{
13011300
"data": {
13021301
"application/vnd.jupyter.widget-view+json": {
1303-
"model_id": "ffb4353460494a15ab0c0e9299dde120",
1302+
"model_id": "562f60dcb79f4651953d34fd40c1cab7",
13041303
"version_major": 2,
13051304
"version_minor": 0
13061305
},
@@ -1382,7 +1381,7 @@
13821381
" posterior = update(likelihood, prior)\n",
13831382
" prior = predict(posterior, 1, kernel)\n",
13841383
" plt.subplot(5, 2, i+1)\n",
1385-
" book_plots.bar_plot(posterior, ylim=(0, .4), title='step {}'.format(i+1))\n",
1384+
" book_plots.bar_plot(posterior, ylim=(0, .4), title=f'step {i+1}')\n",
13861385
" plt.tight_layout()"
13871386
]
13881387
},
@@ -1515,13 +1514,9 @@
15151514
" index = np.argmax(posterior)\n",
15161515
"\n",
15171516
" if do_print:\n",
1518-
" print('''time {}: pos {}, sensed {}, '''\n",
1519-
" '''at position {}'''.format(\n",
1520-
" i, robot.pos, m, track[robot.pos]))\n",
1521-
"\n",
1522-
" print(''' estimated position is {}'''\n",
1523-
" ''' with confidence {:.4f}%:'''.format(\n",
1524-
" index, posterior[index]*100)) \n",
1517+
" print(f'time {i}: pos {robot.pos}, sensed {m}, at position {track[robot.pos]}')\n",
1518+
" conf = posterior[index] * 100\n",
1519+
" print(f' estimated position is {index} with confidence {conf:.4f}%:') \n",
15251520
"\n",
15261521
" book_plots.bar_plot(posterior)\n",
15271522
" if do_print:\n",
@@ -1661,7 +1656,7 @@
16611656
" train_filter(148+i, kernel=[.1, .8, .1], \n",
16621657
" sensor_accuracy=.8,\n",
16631658
" move_distance=4, do_print=False)\n",
1664-
" plt.title ('iteration {}'.format(148+i))"
1659+
" plt.title (f'iteration {148 + i}')"
16651660
]
16661661
},
16671662
{
@@ -1777,7 +1772,7 @@
17771772
"name": "python",
17781773
"nbconvert_exporter": "python",
17791774
"pygments_lexer": "ipython3",
1780-
"version": "3.7.6"
1775+
"version": "3.7.4"
17811776
},
17821777
"widgets": {
17831778
"application/vnd.jupyter.widget-state+json": {

0 commit comments

Comments
 (0)