Renamed Chapters
Renamed chapters to make them easier to work with from the command line using tab completion.
This commit is contained in:
1 parent
c0a6731401
commit
64691d36a2
24 files changed
+24
-20
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,474 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:11378055d75c3ef8b1a2626c65ada84eefab1a411a1267ea328b2466f389e8e9"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
"worksheets": [
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"\n",
|
||||
"from __future__ import division, print_function\n",
|
||||
"%matplotlib inline\n",
|
||||
"import sys\n",
|
||||
"sys.path.insert(0,'../code') # allow us to format the book\n",
|
||||
"\n",
|
||||
"# use same formatting as rest of book so that the plots are\n",
|
||||
"# consistant with that look and feel.\n",
|
||||
"import book_format\n",
|
||||
"book_format.load_style()"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"html": [
|
||||
"<style>\n",
|
||||
"@import url('http://fonts.googleapis.com/css?family=Source+Code+Pro');\n",
|
||||
"\n",
|
||||
" div.cell{\n",
|
||||
" width: 850px;\n",
|
||||
" margin-left: 0% !important;\n",
|
||||
" margin-right: auto;\n",
|
||||
" }\n",
|
||||
" div.text_cell code {\n",
|
||||
" background: transparent;\n",
|
||||
" color: #000000;\n",
|
||||
" font-weight: 600;\n",
|
||||
" font-size: 11pt;\n",
|
||||
" font-style: bold;\n",
|
||||
" font-family: 'Source Code Pro', Consolas, monocco, monospace;\n",
|
||||
" }\n",
|
||||
" h1 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
"\t}\n",
|
||||
"\t\n",
|
||||
" div.input_area {\n",
|
||||
" background: #F6F6F9;\n",
|
||||
" border: 1px solid #586e75;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .text_cell_render h1 {\n",
|
||||
" font-weight: 200;\n",
|
||||
" font-size: 30pt;\n",
|
||||
" line-height: 100%;\n",
|
||||
" color:#c76c0c;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 1em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: wrap;\n",
|
||||
" } \n",
|
||||
" h2 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h2 {\n",
|
||||
" font-weight: 200;\n",
|
||||
" font-size: 20pt;\n",
|
||||
" font-style: italic;\n",
|
||||
" line-height: 100%;\n",
|
||||
" color:#c76c0c;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 1.5em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" } \n",
|
||||
" h3 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h3 {\n",
|
||||
" font-weight: 300;\n",
|
||||
" font-size: 18pt;\n",
|
||||
" line-height: 100%;\n",
|
||||
" color:#d77c0c;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 2em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" }\n",
|
||||
" h4 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h4 {\n",
|
||||
" font-weight: 300;\n",
|
||||
" font-size: 16pt;\n",
|
||||
" color:#d77c0c;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" }\n",
|
||||
" h5 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h5 {\n",
|
||||
" font-weight: 300;\n",
|
||||
" font-style: normal;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" font-size: 16pt;\n",
|
||||
" margin-bottom: 0em;\n",
|
||||
" margin-top: 1.5em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" }\n",
|
||||
" div.text_cell_render{\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" line-height: 135%;\n",
|
||||
" font-size: 110%;\n",
|
||||
" width:750px;\n",
|
||||
" margin-left:auto;\n",
|
||||
" margin-right:auto;\n",
|
||||
" text-align:justify;\n",
|
||||
" text-justify:inter-word;\n",
|
||||
" }\n",
|
||||
" div.output_subarea.output_text.output_pyout {\n",
|
||||
" overflow-x: auto;\n",
|
||||
" overflow-y: scroll;\n",
|
||||
" max-height: 300px;\n",
|
||||
" }\n",
|
||||
" div.output_subarea.output_stream.output_stdout.output_text {\n",
|
||||
" overflow-x: auto;\n",
|
||||
" overflow-y: scroll;\n",
|
||||
" max-height: 300px;\n",
|
||||
" }\n",
|
||||
" code{\n",
|
||||
" font-size: 70%;\n",
|
||||
" }\n",
|
||||
" .rendered_html code{\n",
|
||||
" background-color: transparent;\n",
|
||||
" }\n",
|
||||
" ul{\n",
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" }\n",
|
||||
" ul li li{\n",
|
||||
" padding-left: 0.2em; \n",
|
||||
" margin-bottom: 0.2em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" }\n",
|
||||
" ol{\n",
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ol li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" }\n",
|
||||
" a:link{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:visited{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:hover{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:focus{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:active{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" .rendered_html :link {\n",
|
||||
" text-decoration: underline; \n",
|
||||
" }\n",
|
||||
" .rendered_html :hover {\n",
|
||||
" text-decoration: none; \n",
|
||||
" }\n",
|
||||
" .rendered_html :visited {\n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .rendered_html :focus {\n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .rendered_html :active {\n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .warning{\n",
|
||||
" color: rgb( 240, 20, 20 )\n",
|
||||
" } \n",
|
||||
" hr {\n",
|
||||
" color: #f3f3f3;\n",
|
||||
" background-color: #f3f3f3;\n",
|
||||
" height: 1px;\n",
|
||||
" }\n",
|
||||
" blockquote{\n",
|
||||
" display:block;\n",
|
||||
" background: #fcfcfc;\n",
|
||||
" border-left: 5px solid #c76c0c;\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" width:680px;\n",
|
||||
" padding: 10px 10px 10px 10px;\n",
|
||||
" text-align:justify;\n",
|
||||
" text-justify:inter-word;\n",
|
||||
" }\n",
|
||||
" blockquote p {\n",
|
||||
" margin-bottom: 0;\n",
|
||||
" line-height: 125%;\n",
|
||||
" font-size: 100%;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<script>\n",
|
||||
" MathJax.Hub.Config({\n",
|
||||
" TeX: {\n",
|
||||
" extensions: [\"AMSmath.js\"]\n",
|
||||
" },\n",
|
||||
" tex2jax: {\n",
|
||||
" inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
|
||||
" displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
|
||||
" },\n",
|
||||
" displayAlign: 'center', // Change this to 'center' to center equations.\n",
|
||||
" \"HTML-CSS\": {\n",
|
||||
" styles: {'.MathJax_Display': {\"margin\": 4}}\n",
|
||||
" }\n",
|
||||
" });\n",
|
||||
"</script>\n"
|
||||
],
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 1,
|
||||
"text": [
|
||||
"<IPython.core.display.HTML at 0x7f829807fa58>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 1
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"This notebook creates the animations for the Kalman Filter chapter. It is not really intended to be a readable part of the book, but of course you are free to look at the source code, and even modify it. However, if you are interested in running your own animations, I'll point you to the examples subdirectory of the book, which contains a number of python scripts that you can run and modify from an IDE or the command line. This module saves the animations to GIF files, which is quite slow and not very interactive. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"def plot_3d_covariance(ax, mean, cov):\n",
|
||||
" \"\"\" plots a 2x2 covariance matrix positioned at mean. mean will be plotted\n",
|
||||
" in x and y, and the probability in the z axis.\n",
|
||||
"\n",
|
||||
" Parameters\n",
|
||||
" ----------\n",
|
||||
" mean : 2x1 tuple-like object\n",
|
||||
" mean for x and y coordinates. For example (2.3, 7.5)\n",
|
||||
"\n",
|
||||
" cov : 2x2 nd.array\n",
|
||||
" the covariance matrix\n",
|
||||
"\n",
|
||||
" \"\"\"\n",
|
||||
"\n",
|
||||
" # compute width and height of covariance ellipse so we can choose\n",
|
||||
" # appropriate ranges for x and y\n",
|
||||
" o,w,h = stats.covariance_ellipse(cov,3)\n",
|
||||
" # rotate width and height to x,y axis\n",
|
||||
" wx = abs(w*np.cos(o) + h*np.sin(o))*1.2\n",
|
||||
" wy = abs(h*np.cos(o) - w*np.sin(o))*1.2\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" # ensure axis are of the same size so everything is plotted with the same\n",
|
||||
" # scale\n",
|
||||
" if wx > wy:\n",
|
||||
" w = wx\n",
|
||||
" else:\n",
|
||||
" w = wy\n",
|
||||
"\n",
|
||||
" minx = mean[0] - w\n",
|
||||
" maxx = mean[0] + w\n",
|
||||
" miny = mean[1] - w\n",
|
||||
" maxy = mean[1] + w\n",
|
||||
"\n",
|
||||
" xs = np.arange(minx, maxx, (maxx-minx)/40.)\n",
|
||||
" ys = np.arange(miny, maxy, (maxy-miny)/40.)\n",
|
||||
" xv, yv = np.meshgrid (xs, ys)\n",
|
||||
"\n",
|
||||
" zs = np.array([100.* stats.multivariate_gaussian(np.array([x,y]),mean,cov) \\\n",
|
||||
" for x,y in zip(np.ravel(xv), np.ravel(yv))])\n",
|
||||
" zv = zs.reshape(xv.shape)\n",
|
||||
"\n",
|
||||
" ax = plt.figure().add_subplot(111, projection='3d')\n",
|
||||
" ax.plot_surface(xv, yv, zv, rstride=1, cstride=1, cmap=cm.autumn)\n",
|
||||
"\n",
|
||||
" ax.set_xlabel('X')\n",
|
||||
" ax.set_ylabel('Y')\n",
|
||||
"\n",
|
||||
" ax.contour(xv, yv, zv, zdir='x', offset=minx-1, cmap=cm.autumn)\n",
|
||||
" ax.contour(xv, yv, zv, zdir='y', offset=maxy, cmap=cm.BuGn)\n"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 1
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"from __future__ import print_function, division\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy.random as random\n",
|
||||
"import math\n",
|
||||
"import stats\n",
|
||||
"from gif_animate import animate\n",
|
||||
"\n",
|
||||
"def update(mu1, var1, mu2, var2):\n",
|
||||
" mean = (var1*mu2 + var2*mu1) / (var1+var2)\n",
|
||||
" variance = 1 / (1/var1 + 1/var2)\n",
|
||||
" return (mean, variance)\n",
|
||||
"\n",
|
||||
"def predict(pos, variance, movement, movement_variance):\n",
|
||||
" return (pos + movement, variance + movement_variance)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"sensor_error = 1.2**2\n",
|
||||
"movement_error = .2\n",
|
||||
"movement = 0\n",
|
||||
"voltage = (25,20) #who knows what the first value is?\n",
|
||||
"\n",
|
||||
"volts = [14.44, 18.74, 17.21, 15.98, 16.76, 14.8, 16.01, 16.90, 15.41, 17.31,\n",
|
||||
" 16.39, 17.96]\n",
|
||||
"ps = [voltage[0]]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"i = 0\n",
|
||||
"pred = 0\n",
|
||||
"def volt_animate(frame):\n",
|
||||
" global i, ps, voltage, Z, x, pred\n",
|
||||
" \n",
|
||||
" step = frame % 4\n",
|
||||
" plt.subplot(211)\n",
|
||||
" plt.ylim([14,26])\n",
|
||||
"\n",
|
||||
" if step == 0:\n",
|
||||
" prev = voltage[0]\n",
|
||||
" voltage = predict(voltage[0], voltage[1], movement, movement_error)\n",
|
||||
" pred = voltage[0]\n",
|
||||
" plt.plot ([i, i+1], [prev, pred], c='g') \n",
|
||||
" \n",
|
||||
" elif step == 1:\n",
|
||||
" Z = volts[i]\n",
|
||||
" i += 1\n",
|
||||
" \n",
|
||||
" plt.scatter(i, Z, marker='+', s=64, color='r')\n",
|
||||
"\n",
|
||||
" elif step == 2:\n",
|
||||
" plt.plot ([i,i], [pred, Z], c='r', alpha=0.3)\n",
|
||||
"\n",
|
||||
" else:\n",
|
||||
" voltage = update(voltage[0], voltage[1], Z, sensor_error)\n",
|
||||
" ps.append(voltage[0])\n",
|
||||
" plt.plot(ps, c='b')\n",
|
||||
" \n",
|
||||
" plt.subplot(212)\n",
|
||||
" plt.cla()\n",
|
||||
" stats.plot_gaussian(voltage[0], voltage[1], xlim=[0,32])\n",
|
||||
" plt.ylim([0,1])\n",
|
||||
" plt.tight_layout()\n",
|
||||
" \n",
|
||||
"N=12\n",
|
||||
"animate('volt_animate.gif', volt_animate, N*3, 350)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"png": "iVBORw0KGgoAAAANSUhEUgAAAcsAAAHKCAYAAABsXmDiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl8VOXd///XJJnJSoAkEDCSsG8GBVFcwEQU1Iitv8a6\nFG/AH7doSxSLVm+14m1FsYuF9q5LxeVGva0LUoUWpEpVIiK4L0BYkpBVwhIC2SeZ5fvHZAZiSCbJ\nTHImmffz8eCRM9s5n7ky5D3XOde5jmnPnj1OREREpFUhRhcgIiIS6BSWIiIiXigsRUREvFBYioiI\neKGwFBER8UJhKSIi4oXCUkRExAufwtJms3HPPfcwbdo0zjnnHObOnUtubq7n8VWrVjF9+nQmTZpE\nZmYmTqdO6RQRkZ7Hp7B0OBykpKSwZs0aPv/8cy655BKysrIAWL9+PatWreLJJ5/kq6++4re//S0m\nk8kvRYuIiHQnkz9n8KmsrGTKlCls3bqVO+64gyuvvJKf/exn/lq9iIiIIfx6zPKrr74iMTGR/v37\ns2fPHsrLy5k5cybTp0/nL3/5iz83JSIi0m3C/LWiqqoqli1bxr333ovJZKKqqors7Gxef/11rFYr\nN954I+PGjWPGjBn+2qSIiEi38EtYNjQ0kJWVxaxZs8jIyAAgMjKSzMxM4uLiALjsssvYvn17i7As\nLi72RwkiIiLtNmTIkA493+ewtNvt3HnnnQwdOpRFixZ57k9OTm72vLZGwo4bN87XMnqN+Ph4/v73\nv5Oenm50KQFDbdKS2qQltUlLapOW4uPj2bJlS4df5/MxywcffJC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r\n1qzh888/55JLLiErKwuAVatWkZubS3Z2Nr/73e+4//77KSsr80vR4t2OHRajSxAR6TV8CkuLxUJW\nVhaJiYkAZGZmUlhYyNGjR9m4cSNz5swhJiaGKVOmMGnSJN577z2/FC1t0eQEIiL+5tdjll999RWJ\niYn079+fgoIChg0bxq9+9Ss2bNjAiBEj2L9/vz83J6eQkKBBPiIi/hbmrxVVVVWxbNky7r33Xkwm\nE3V1dURFRbFv3z5SU1OJjo5udTdsfLwm/3Yzm11zu3a2TV56yc6VV4YC8Oab8dx6a+fqCIl1navp\nCIDfja9t0hupTVpSm7SkNmnJ3SYd5ZewbGhoICsri1mzZpGRkQFAZGQkdXV1rF27FoBHHnmE6Ojo\nU75+6dKlnuW0tDTS09P9UVZQuuQS95KJJUvCuPVWm5HliIgYbvPmzWRnZwMQGhpKWlpah9fhc1ja\n7XbuvPNOhg4dyqJFizz3Dx06lLy8PM444wwA8vLyuPTSS0+5joULFza7XV5e7mtZPZb7G6BvbTAY\ngMpKU6fXE15ZCYA1AH4X/mmT3kVt0pLapCW1iUtqaiqpqamAq022bNnS4XX4fMzywQcfJCQkhIce\neqjZ/RkZGbz88stUVVWxfft2vv76a2bOnOnr5qQdQkOdTUsa5CMi4g8+9SxLS0tZs2YNkZGRTJ48\n2XP/c889x0033UR+fj7p6en07duXZcuWeUbNStdKT6/j/fddu7zr6iBS86qLiPjEp7BMSkpi9+7d\nrT6+bNkyli1b5ssmpBNWrjzOyJFRgIn/+I9+rFlzzOiSRER6NE131wud3JP87LMI4woREeLine truncated
|
||||
"text": [
|
||||
"<matplotlib.figure.Figure at 0x7f82796e75c0>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 2
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<img src='volt_animate.gif'>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"# assume dog is always moving 1m to the right\n",
|
||||
"movement = 1\n",
|
||||
"movement_error = .05\n",
|
||||
"sensor_error = 4.5\n",
|
||||
"pos = (0, 100) # gaussian N(0,100)\n",
|
||||
"\n",
|
||||
"# this is the recorded output of a run of the dog sensor with an initial\n",
|
||||
"# seed of 200\n",
|
||||
"ZS = [-2.07, 6.05, 4.51, 3.47, 5.76, 5.93, 6.53, 9.01, 7.53, 11.68, \n",
|
||||
" 11.15, 14.76, 13.45, 16.15, 19.05, 14.87, 20.90, 15.75, \n",
|
||||
" 17.16, 20.50]\n",
|
||||
"zs = []\n",
|
||||
"ps = []\n",
|
||||
"\n",
|
||||
"N=20\n",
|
||||
"\n",
|
||||
"def dog_animate(frame):\n",
|
||||
" global pos, zs, ps, N, ZS\n",
|
||||
" pos = predict(pos[0], pos[1], movement, movement_error) \n",
|
||||
" Z = ZS[frame]\n",
|
||||
" zs.append(Z)\n",
|
||||
" \n",
|
||||
" pos = update(pos[0], pos[1], Z, sensor_error)\n",
|
||||
" ps.append(pos[0])\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" plt.subplot(211)\n",
|
||||
" plt.plot(zs,c='r', linestyle='dashed')\n",
|
||||
"\n",
|
||||
" plt.xlim([0,N*1.2])\n",
|
||||
" plt.ylim([0,N*1.2])\n",
|
||||
"\n",
|
||||
" if len(ps) > 1:\n",
|
||||
" plt.plot(ps, c='#8EBA42')\n",
|
||||
" \n",
|
||||
" plt.subplot(212)\n",
|
||||
" plt.cla()\n",
|
||||
" stats.plot_gaussian(pos[0], pos[1], xlim=[0,N*1.2])\n",
|
||||
" plt.ylim([0,1])\n",
|
||||
" plt.tight_layout()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"animate('dog_track.gif', dog_animate, N, 200)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<img src='dog_track.gif'>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 238 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 481 KiB |
Reference in new issue
Block a user