|
20 | 20 | "metadata": {}, |
21 | 21 | "outputs": [], |
22 | 22 | "source": [ |
23 | | - "from __future__ import division, print_function\n", |
24 | 23 | "%matplotlib inline" |
25 | 24 | ] |
26 | 25 | }, |
|
36 | 35 | " <style>\n", |
37 | 36 | " .output_wrapper, .output {\n", |
38 | 37 | " height:auto !important;\n", |
39 | | - " max-height:100000px; \n", |
| 38 | + " max-height:100000px;\n", |
40 | 39 | " }\n", |
41 | 40 | " .output_scroll {\n", |
42 | 41 | " box-shadow:none !important;\n", |
|
582 | 581 | { |
583 | 582 | "data": { |
584 | 583 | "application/vnd.jupyter.widget-view+json": { |
585 | | - "model_id": "6a0f5d2b16e54121bd8a3b11957d0966", |
| 584 | + "model_id": "69e1cf784fd743ddaeae41d5fa161216", |
586 | 585 | "version_major": 2, |
587 | 586 | "version_minor": 0 |
588 | 587 | }, |
|
758 | 757 | { |
759 | 758 | "data": { |
760 | 759 | "application/vnd.jupyter.widget-view+json": { |
761 | | - "model_id": "5e1bbeaf87af4835869cd7a6676fa209", |
| 760 | + "model_id": "b7f90f29b9394f82b4c64982c8eab901", |
762 | 761 | "version_major": 2, |
763 | 762 | "version_minor": 0 |
764 | 763 | }, |
|
783 | 782 | "# make interactive plot\n", |
784 | 783 | "def show_prior(step):\n", |
785 | 784 | " book_plots.bar_plot(predict_beliefs[step-1])\n", |
786 | | - " plt.title('Step {}'.format(step))\n", |
| 785 | + " plt.title(f'Step {step}')\n", |
787 | 786 | "\n", |
788 | 787 | "interact(show_prior, step=IntSlider(value=1, max=len(predict_beliefs)));" |
789 | 788 | ] |
|
1247 | 1246 | { |
1248 | 1247 | "data": { |
1249 | 1248 | "application/vnd.jupyter.widget-view+json": { |
1250 | | - "model_id": "9f7338d5d95a4133ae3825b18020b9cd", |
| 1249 | + "model_id": "5e52dc4ac04b4244ad4357a4fd837902", |
1251 | 1250 | "version_major": 2, |
1252 | 1251 | "version_minor": 0 |
1253 | 1252 | }, |
|
1300 | 1299 | { |
1301 | 1300 | "data": { |
1302 | 1301 | "application/vnd.jupyter.widget-view+json": { |
1303 | | - "model_id": "ffb4353460494a15ab0c0e9299dde120", |
| 1302 | + "model_id": "562f60dcb79f4651953d34fd40c1cab7", |
1304 | 1303 | "version_major": 2, |
1305 | 1304 | "version_minor": 0 |
1306 | 1305 | }, |
|
1382 | 1381 | " posterior = update(likelihood, prior)\n", |
1383 | 1382 | " prior = predict(posterior, 1, kernel)\n", |
1384 | 1383 | " 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", |
1386 | 1385 | " plt.tight_layout()" |
1387 | 1386 | ] |
1388 | 1387 | }, |
|
1515 | 1514 | " index = np.argmax(posterior)\n", |
1516 | 1515 | "\n", |
1517 | 1516 | " 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", |
1525 | 1520 | "\n", |
1526 | 1521 | " book_plots.bar_plot(posterior)\n", |
1527 | 1522 | " if do_print:\n", |
|
1661 | 1656 | " train_filter(148+i, kernel=[.1, .8, .1], \n", |
1662 | 1657 | " sensor_accuracy=.8,\n", |
1663 | 1658 | " move_distance=4, do_print=False)\n", |
1664 | | - " plt.title ('iteration {}'.format(148+i))" |
| 1659 | + " plt.title (f'iteration {148 + i}')" |
1665 | 1660 | ] |
1666 | 1661 | }, |
1667 | 1662 | { |
|
1777 | 1772 | "name": "python", |
1778 | 1773 | "nbconvert_exporter": "python", |
1779 | 1774 | "pygments_lexer": "ipython3", |
1780 | | - "version": "3.7.6" |
| 1775 | + "version": "3.7.4" |
1781 | 1776 | }, |
1782 | 1777 | "widgets": { |
1783 | 1778 | "application/vnd.jupyter.widget-state+json": { |
|
0 commit comments