|
22 | 22 | "# How to make code beautiful\n",
|
23 | 23 | "### Python beyond basics\n",
|
24 | 24 | "\n",
|
25 |
| - "<br><br><br><br><br><br>\n", |
| 25 | + "<br><br><br><br><br><br><br><br><br><br><br><br>\n", |
26 | 26 | "<div style=\"font-size:0.8em; color: #555\">2019-04-03 Session 2\n",
|
27 | 27 | "<span style=\"float:right\">Peter Regner</span>\n",
|
28 | 28 | "</div>"
|
|
262 | 262 | {
|
263 | 263 | "cell_type": "code",
|
264 | 264 | "execution_count": 3,
|
265 |
| - "metadata": { |
266 |
| - "slideshow": { |
267 |
| - "slide_type": "fragment" |
268 |
| - } |
269 |
| - }, |
| 265 | + "metadata": {}, |
270 | 266 | "outputs": [],
|
271 | 267 | "source": [
|
272 | 268 | "import antigravity"
|
|
283 | 279 | "outputs": [],
|
284 | 280 | "source": [
|
285 | 281 | "import sys\n",
|
286 |
| - "if 'this' in sys.modules:\n", |
| 282 | + "if 'antigravity' in sys.modules:\n", |
287 | 283 | " del sys.modules['antigravity']"
|
288 | 284 | ]
|
289 | 285 | },
|
|
474 | 470 | {
|
475 | 471 | "cell_type": "code",
|
476 | 472 | "execution_count": 6,
|
477 |
| - "metadata": {}, |
478 |
| - "outputs": [ |
479 |
| - { |
480 |
| - "name": "stdout", |
481 |
| - "output_type": "stream", |
482 |
| - "text": [ |
483 |
| - "Way better! Great! 👍\n" |
484 |
| - ] |
| 473 | + "metadata": { |
| 474 | + "slideshow": { |
| 475 | + "slide_type": "fragment" |
485 | 476 | }
|
486 |
| - ], |
| 477 | + }, |
| 478 | + "outputs": [], |
487 | 479 | "source": [
|
488 |
| - "twitter_search('obama', numtweets=0, retweets=False, unicode=True)" |
| 480 | + "ts('obama', False, 20, True)" |
489 | 481 | ]
|
490 | 482 | },
|
491 | 483 | {
|
|
1834 | 1826 | "slide_type": "skip"
|
1835 | 1827 | }
|
1836 | 1828 | },
|
1837 |
| - "outputs": [ |
1838 |
| - { |
1839 |
| - "name": "stdout", |
1840 |
| - "output_type": "stream", |
1841 |
| - "text": [ |
1842 |
| - "Populating the interactive namespace from numpy and matplotlib\n" |
1843 |
| - ] |
1844 |
| - }, |
1845 |
| - { |
1846 |
| - "name": "stderr", |
1847 |
| - "output_type": "stream", |
1848 |
| - "text": [ |
1849 |
| - "/home/peter/.local/lib/python3.6/site-packages/IPython/core/magics/pylab.py:160: UserWarning: pylab import has clobbered these variables: ['f', 'datetime']\n", |
1850 |
| - "`%matplotlib` prevents importing * from pylab and numpy\n", |
1851 |
| - " \"\\n`%matplotlib` prevents importing * from pylab and numpy\"\n" |
1852 |
| - ] |
1853 |
| - } |
1854 |
| - ], |
| 1829 | + "outputs": [], |
1855 | 1830 | "source": [
|
1856 |
| - "from scipy.interpolate import interp1d\n", |
1857 |
| - "%pylab inline" |
| 1831 | + "%matplotlib inline\n", |
| 1832 | + "import numpy as np\n", |
| 1833 | + "import matplotlib.pyplot as plt\n", |
| 1834 | + "from scipy.interpolate import interp1d" |
1858 | 1835 | ]
|
1859 | 1836 | },
|
1860 | 1837 | {
|
|
1919 | 1896 | "def plot_func(func):\n",
|
1920 | 1897 | " x = np.linspace(0, 4, num=20)\n",
|
1921 | 1898 | " y = func(x)\n",
|
1922 |
| - " plot(x, y, 'o-')\n", |
| 1899 | + " plt.plot(x, y, 'o-')\n", |
1923 | 1900 | " \n",
|
1924 | 1901 | "plot_func(power_curve)"
|
1925 | 1902 | ]
|
|
3558 | 3535 | "def print_meaning():\n",
|
3559 | 3536 | " print(42)\n",
|
3560 | 3537 | " \n",
|
3561 |
| - "print_meaning()" |
| 3538 | + "call_print_meaning()" |
3562 | 3539 | ]
|
3563 | 3540 | },
|
3564 | 3541 | {
|
|
4158 | 4135 | },
|
4159 | 4136 | "outputs": [],
|
4160 | 4137 | "source": [
|
4161 |
| - "with open('turbine_models.csv') as f:\n", |
| 4138 | + "with open('data-samples/turbine_models.csv') as f:\n", |
4162 | 4139 | " 1/0"
|
4163 | 4140 | ]
|
4164 | 4141 | },
|
|
5287 | 5264 | "\n",
|
5288 | 5265 | "\n",
|
5289 | 5266 | "- empty tuple: **`()`**\n",
|
5290 |
| - "- list with one element: **`(42,)`** or in some case allowed **`42,`**\n", |
5291 |
| - "- list with many elements: **`(1,2,3)`** or **`(1,2,3,)`** or in some cases allowed **`1,2,3`** or **`1,2,3,`**" |
| 5267 | + "- tuple with one element: **`(42,)`** or in some case allowed **`42,`**\n", |
| 5268 | + "- tuple with many elements: **`(1,2,3)`** or **`(1,2,3,)`** or in some cases allowed **`1,2,3`** or **`1,2,3,`**" |
5292 | 5269 | ]
|
5293 | 5270 | },
|
5294 | 5271 | {
|
|
0 commit comments