Last active
March 19, 2017 06:11
-
-
Save BrianChevalier/81bf87c9498f78b37a43dd430101b463 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Import Packages" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"from numpy import array\n", | |
"from numpy import matrix\n", | |
"import pandas as pd" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Input Physical Probelm Data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gravity = 9.81 # acceleration of gravity\n", | |
"e3 = array([0, 0, 1]) # direction of gravity (e3)\n", | |
"mass = 2.0 # mass of particle" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Initial conditions and analysis start and end times " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"xo = array([0.0, 0.0, 55.0]) # initial position of particle\n", | |
"vo = array([25.0, 15.0, 55.0]) # initial velocity of particle\n", | |
"to = 0.0 # initial time (usually zero)\n", | |
"tf = 12.5 # final time (end of analysis)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"#.... Numerical analysis parameters.\n", | |
"dt = 0.1 # analysis time step\n", | |
"beta = 0.5 # numerical integration parameter\n", | |
"\n", | |
"#.... Set time and output counters to get ready to start analysis\n", | |
"t = to; \n", | |
"out = 0; \n", | |
"iout = 0;\n", | |
" \n", | |
"#.... Initialize position and velocity (put in 'xold' and 'vold' arrays)\n", | |
"xold = xo;\n", | |
"vold = vo; \n", | |
"\n", | |
"#.... Compute initial acceleration from the equation of motion\n", | |
"aold = -gravity*e3;\n", | |
" " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# Note: All arguments are required.\n", | |
"# We're not fancy enough to implement all.\n", | |
"def frange(start, stop, step):\n", | |
" i = start\n", | |
" while i < stop:\n", | |
" yield i\n", | |
" i += step\n", | |
"\n", | |
"#for i in frange(0.5, 1, 0.1):\n", | |
" #print(i)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"def update(xold, vold, anew, aold):\n", | |
" beta = 0.5\n", | |
" dt = 0.1\n", | |
" #....... Compute new velocity and position by trapezoidal rule \n", | |
" vnew = vold + dt*(beta*aold + (1-beta)*anew)\n", | |
" xnew = xold + dt*(beta*vold + (1-beta)*vnew)\n", | |
" \n", | |
" #....... Put current state (new) into old slot to get ready for new step\n", | |
" aold = anew\n", | |
" vold = vnew\n", | |
" xold = xnew\n", | |
" return (xold, vold, aold)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Set up the history matrix" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" xx xy xz\n", | |
"t \n", | |
"0.0 0.0 0.0 55.0\n" | |
] | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"import pandas as pd\n", | |
"import matplotlib.pyplot as plt\n", | |
"\n", | |
"#history = {'t' : [to], 'xold' : [xo], 'vold' : [vo], 'aold' : [aold]}\n", | |
"history = {'t' : [to], 'xx' : [xo[0]], 'xy' : [xo[1]], 'xz' : [xo[2]]}\n", | |
"\n", | |
"#new = {'t' : to+1, 'x': 1,'y': 1,'z': 3}\n", | |
"\n", | |
"#for item in history:\n", | |
"# history[item].append(new[item])\n", | |
"\n", | |
"df = pd.DataFrame(history)\n", | |
"print(df.set_index('t'))\n", | |
"\n", | |
"#for item in plt.style.available:\n", | |
"# plt.style.use(item)\n", | |
"# df.plot.line(['t'])\n", | |
"# plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Compute motion by numerical integration\n", | |
"- loop over time steps" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" xx xy xz\n", | |
"t \n", | |
"0.0 0 0 55\n", | |
"[0.0] [630.0] [378.0] [-1673.8712]\n", | |
"[0.1] [632.5] [379.5] [-1693.14145]\n", | |
"[0.2] [635.0] [381.0] [-1712.5098]\n", | |
"[0.30000000000000004] [637.5] [382.5] [-1731.97625]\n", | |
"[0.4] [640.0] [384.0] [-1751.5408]\n", | |
"[0.5] [642.5] [385.5] [-1771.20345]\n", | |
"[0.6] [645.0] [387.0] [-1790.9642]\n", | |
"[0.7] [647.5] [388.5] [-1810.82305]\n", | |
"[0.7999999999999999] [650.0] [390.0] [-1830.78]\n", | |
"[0.8999999999999999] [652.5] [391.5] [-1850.83505]\n", | |
"[0.9999999999999999] [655.0] [393.0] [-1870.9882]\n", | |
"[1.0999999999999999] [657.5] [394.5] [-1891.23945]\n", | |
"[1.2] [660.0] [396.0] [-1911.5888]\n", | |
"[1.3] [662.5] [397.5] [-1932.03625]\n", | |
"[1.4000000000000001] [665.0] [399.0] [-1952.5818]\n", | |
"[1.5000000000000002] [667.5] [400.5] [-1973.22545]\n", | |
"[1.6000000000000003] [670.0] [402.0] [-1993.9672]\n", | |
"[1.7000000000000004] [672.5] [403.5] [-2014.80705]\n", | |
"[1.8000000000000005] [675.0] [405.0] [-2035.745]\n", | |
"[1.9000000000000006] [677.5] [406.5] [-2056.78105]\n", | |
"[2.0000000000000004] [680.0] [408.0] [-2077.9152]\n", | |
"[2.1000000000000005] [682.5] [409.5] [-2099.14745]\n", | |
"[2.2000000000000006] [685.0] [411.0] [-2120.4778]\n", | |
"[2.3000000000000007] [687.5] [412.5] [-2141.90625]\n", | |
"[2.400000000000001] [690.0] [414.0] [-2163.4328]\n", | |
"[2.500000000000001] [692.5] [415.5] [-2185.05745]\n", | |
"[2.600000000000001] [695.0] [417.0] [-2206.7802]\n", | |
"[2.700000000000001] [697.5] [418.5] [-2228.60105]\n", | |
"[2.800000000000001] [700.0] [420.0] [-2250.52]\n", | |
"... ... ... ...\n", | |
"[9.599999999999982] [1815.0] [1089.0] [-21805.0778]\n", | |
"[9.699999999999982] [1817.5] [1090.5] [-21870.84745]\n", | |
"[9.799999999999981] [1820.0] [1092.0] [-21936.7152]\n", | |
"[9.89999999999998] [1822.5] [1093.5] [-22002.68105]\n", | |
"[9.99999999999998] [1825.0] [1095.0] [-22068.745]\n", | |
"[10.09999999999998] [1827.5] [1096.5] [-22134.90705]\n", | |
"[10.19999999999998] [1830.0] [1098.0] [-22201.1672]\n", | |
"[10.29999999999998] [1832.5] [1099.5] [-22267.52545]\n", | |
"[10.399999999999979] [1835.0] [1101.0] [-22333.9818]\n", | |
"[10.499999999999979] [1837.5] [1102.5] [-22400.53625]\n", | |
"[10.599999999999978] [1840.0] [1104.0] [-22467.1888]\n", | |
"[10.699999999999978] [1842.5] [1105.5] [-22533.93945]\n", | |
"[10.799999999999978] [1845.0] [1107.0] [-22600.7882]\n", | |
"[10.899999999999977] [1847.5] [1108.5] [-22667.73505]\n", | |
"[10.999999999999977] [1850.0] [1110.0] [-22734.78]\n", | |
"[11.099999999999977] [1852.5] [1111.5] [-22801.92305]\n", | |
"[11.199999999999976] [1855.0] [1113.0] [-22869.1642]\n", | |
"[11.299999999999976] [1857.5] [1114.5] [-22936.50345]\n", | |
"[11.399999999999975] [1860.0] [1116.0] [-23003.9408]\n", | |
"[11.499999999999975] [1862.5] [1117.5] [-23071.47625]\n", | |
"[11.599999999999975] [1865.0] [1119.0] [-23139.1098]\n", | |
"[11.699999999999974] [1867.5] [1120.5] [-23206.84145]\n", | |
"[11.799999999999974] [1870.0] [1122.0] [-23274.6712]\n", | |
"[11.899999999999974] [1872.5] [1123.5] [-23342.59905]\n", | |
"[11.999999999999973] [1875.0] [1125.0] [-23410.625]\n", | |
"[12.099999999999973] [1877.5] [1126.5] [-23478.74905]\n", | |
"[12.199999999999973] [1880.0] [1128.0] [-23546.9712]\n", | |
"[12.299999999999972] [1882.5] [1129.5] [-23615.29145]\n", | |
"[12.399999999999972] [1885.0] [1131.0] [-23683.7098]\n", | |
"[12.499999999999972] [1887.5] [1132.5] [-23752.22625]\n", | |
"\n", | |
"[505 rows x 3 columns]\n" | |
] | |
} | |
], | |
"source": [ | |
"\n", | |
"\n", | |
"for t in frange(to, tf, dt): \n", | |
" \n", | |
" #new = {'t' : t, 'xold[0]': xold,'vold': vold,'aold': aold}\n", | |
" new = {'t' : [t], 'xx' : [xold[0]], 'xy' : [xold[1]], 'xz' : [xold[2]]}\n", | |
"\n", | |
" for item in history:\n", | |
" history[item].append(new[item])\n", | |
"\n", | |
" \n", | |
" #Compute new acceleration from equation of motion \n", | |
" anew = -gravity*e3\n", | |
" (xold, vold, aold) = update(xold, vold, anew, aold)\n", | |
"\n", | |
" \n", | |
" \n", | |
"df = pd.DataFrame(history)\n", | |
"print(df.set_index('t'))\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"ename": "TypeError", | |
"evalue": "float() argument must be a string or a number, not 'dict'", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", | |
"\u001b[0;32m<ipython-input-29-7cb7283dadb7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhistory\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m#for item in plt.style.available:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# plt.style.use(item)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;31m# df.plot.line('t')\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# plt.show()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/matplotlib/pyplot.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 3316\u001b[0m mplDeprecation)\n\u001b[1;32m 3317\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3318\u001b[0;31m \u001b[0mret\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3319\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3320\u001b[0m \u001b[0max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_hold\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mwashold\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/matplotlib/__init__.py\u001b[0m in \u001b[0;36minner\u001b[0;34m(ax, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1890\u001b[0m warnings.warn(msg % (label_namer, func.__name__),\n\u001b[1;32m 1891\u001b[0m RuntimeWarning, stacklevel=2)\n\u001b[0;32m-> 1892\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0max\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1893\u001b[0m \u001b[0mpre_doc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minner\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1894\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mpre_doc\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1405\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1406\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mline\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_lines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1407\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd_line\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1408\u001b[0m \u001b[0mlines\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1409\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36madd_line\u001b[0;34m(self, line)\u001b[0m\n\u001b[1;32m 1785\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_clip_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpatch\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1786\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1787\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_update_line_limits\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1788\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_label\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1789\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_label\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'_line%d'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlines\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36m_update_line_limits\u001b[0;34m(self, line)\u001b[0m\n\u001b[1;32m 1807\u001b[0m \u001b[0mFigures\u001b[0m \u001b[0mout\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mdata\u001b[0m \u001b[0mlimit\u001b[0m \u001b[0mof\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mgiven\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mupdating\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataLim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1808\u001b[0m \"\"\"\n\u001b[0;32m-> 1809\u001b[0;31m \u001b[0mpath\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1810\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvertices\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1811\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/matplotlib/lines.py\u001b[0m in \u001b[0;36mget_path\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 987\u001b[0m \"\"\"\n\u001b[1;32m 988\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_invalidy\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_invalidx\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 989\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecache\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 990\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_path\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 991\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/matplotlib/lines.py\u001b[0m in \u001b[0;36mrecache\u001b[0;34m(self, always)\u001b[0m\n\u001b[1;32m 683\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0myconv\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat_\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfilled\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnan\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 684\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 685\u001b[0;31m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0myconv\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat_\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 686\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mravel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 687\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/Users/BrianBadahdah/anaconda/lib/python3.6/site-packages/numpy/core/numeric.py\u001b[0m in \u001b[0;36masarray\u001b[0;34m(a, dtype, order)\u001b[0m\n\u001b[1;32m 480\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 481\u001b[0m \"\"\"\n\u001b[0;32m--> 482\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 483\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 484\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0masanyarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mTypeError\u001b[0m: float() argument must be a string or a number, not 'dict'" | |
] | |
} | |
], | |
"source": [ | |
"plt.plot(history)\n", | |
"#for item in plt.style.available:\n", | |
"# plt.style.use(item)\n", | |
"# df.plot.line('t')\n", | |
"# plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"2\n", | |
"3\n", | |
"4\n" | |
] | |
} | |
], | |
"source": [ | |
"def f(x):\n", | |
" y0 = x + 1\n", | |
" y1 = x * 3\n", | |
" y2 = y0 ** 2\n", | |
" return (y0,y1,y2)\n", | |
"\n", | |
"(y0,y1,y2) = f(1)\n", | |
"print(y0)\n", | |
"print(y1)\n", | |
"print(y2)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(1.105, 1.1, 1)" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"update(1,1,1,1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"['bmh', 'classic', 'dark_background', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark-palette', 'seaborn-dark', 'seaborn-darkgrid', 'seaborn-deep', 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 'seaborn-pastel', 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'seaborn-whitegrid', 'seaborn']\n" | |
] | |
} | |
], | |
"source": [ | |
"print(plt.style.available)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import seaborn\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment