Sfoglia il codice sorgente

updated example files and final commit

master
Keith 7 anni fa
commit
fabe20a337
5 ha cambiato i file con 24848 aggiunte e 0 eliminazioni
  1. +0
    -0
      README.md
  2. +11960
    -0
      example_document.html
  3. +256
    -0
      example_document.ipynb
  4. +485
    -0
      nbextensions_talk.ipynb
  5. +12147
    -0
      nbextensions_talk.slides.html

+ 0
- 0
README.md Vedi File


+ 11960
- 0
example_document.html
File diff soppresso perché troppo grande
Vedi File


+ 256
- 0
example_document.ipynb Vedi File

@@ -0,0 +1,256 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"toc": "true"
},
"source": [
"# Table of Contents\n",
" <p><div class=\"lev1 toc-item\"><a href=\"#A-Section-for-TOC\" data-toc-modified-id=\"A-Section-for-TOC-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>A Section for TOC</a></div><div class=\"lev1 toc-item\"><a href=\"#Another-section\" data-toc-modified-id=\"Another-section-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>Another section</a></div><div class=\"lev1 toc-item\"><a href=\"#Yet-another-Section\" data-toc-modified-id=\"Yet-another-Section-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>Yet another Section</a></div><div class=\"lev2 toc-item\"><a href=\"#Sub-section\" data-toc-modified-id=\"Sub-section-31\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>Sub-section</a></div><div class=\"lev2 toc-item\"><a href=\"#An-would-you-like-another-sub-section?\" data-toc-modified-id=\"An-would-you-like-another-sub-section?-32\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>An would you like another sub-section?</a></div><div class=\"lev1 toc-item\"><a href=\"#How-is-you-code-feeling-today?\" data-toc-modified-id=\"How-is-you-code-feeling-today?-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>How is you code feeling today?</a></div><div class=\"lev1 toc-item\"><a href=\"#Do-you-get-the-gist-dictionary-comprehensions-all?\" data-toc-modified-id=\"Do-you-get-the-gist-dictionary-comprehensions-all?-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>Do you get the gist dictionary comprehensions all?</a></div><div class=\"lev1 toc-item\"><a href=\"#Would-you-like-some-math?\" data-toc-modified-id=\"Would-you-like-some-math?-6\"><span class=\"toc-item-num\">6&nbsp;&nbsp;</span>Would you like some math?</a></div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# A Section for TOC"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Another section\n",
"\n",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tortor erat, faucibus in faucibus ut, mattis quis ligula. Vivamus ultricies non augue rhoncus placerat. Nulla eleifend, lacus eget fermentum tristique, nisi lectus aliquet risus, at vestibulum dolor mauris quis velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse elementum sapien turpis, in gravida felis iaculis vitae. Donec sodales, erat in rutrum sollicitudin, nisl nisl finibus eros, id blandit enim diam vitae ex. Aliquam et ligula id augue pretium fringilla. Donec turpis mi, pulvinar at velit et, pretium dapibus lorem. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Yet another Section\n",
"Praesent aliquam ornare orci quis blandit. Donec pulvinar lacinia nulla at hendrerit. Morbi sed sem elementum, finibus tellus ac, vestibulum augue. In vestibulum tortor id augue molestie porta. In ut imperdiet dolor. Mauris sit amet condimentum ex, eu blandit quam. Suspendisse quis magna non ante sagittis bibendum. Etiam dictum justo et justo porta, at finibus purus aliquam. Nulla facilisi. In dolor mauris, mollis in blandit vitae, dictum non mauris. Aenean nec arcu vestibulum, maximus sem a, volutpat nisl. Vivamus dignissim ultricies justo. Praesent facilisis magna ac velit vestibulum tincidunt. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sub-section\n",
"Sed commodo ultrices risus, sed feugiat est luctus sed. Duis neque metus, fermentum tincidunt leo in, porttitor ullamcorper nisl. Ut efficitur nibh augue, ac hendrerit velit auctor ac. Aenean aliquet felis nec dui egestas, nec ornare turpis mollis. Nullam luctus viverra fermentum. Vivamus scelerisque nulla in erat rutrum, ac luctus nibh egestas. Donec fringilla augue cursus libero sagittis gravida. In hac habitasse platea dictumst. Morbi dignissim magna vitae justo fermentum, eu fermentum magna efficitur. Sed risus sem, elementum non faucibus at, venenatis ut sem. Nulla facilisi. In diam mauris, tincidunt et velit ac, imperdiet malesuada purus. Praesent hendrerit maximus sapien, eu accumsan magna venenatis eu. Suspendisse potenti. Praesent vitae viverra tellus, at lobortis orci. Quisque eget orci eu metus venenatis ultrices ac sit amet eros. \n",
"\n",
"\n",
"* Morbi eget elit non turpis faucibus condimentum at at felis.\n",
"* Cras dapibus mauris pharetra dictum pretium.\n",
"* Proin eget magna interdum dolor viverra auctor at eu augue.\n",
"* Quisque faucibus sem non turpis bibendum interdum.\n",
"* Donec fringilla elit at consectetur pulvinar.\n",
"* Maecenas vel massa eleifend, pretium tortor vitae, porttitor ligula.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## An would you like another sub-section?\n",
"\n",
"\n",
"\n",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse nulla ligula, auctor non dui sed, lobortis mollis libero. Phasellus maximus quam eget libero blandit, non convallis odio vehicula. Phasellus leo sapien, congue vel sollicitudin vel, dapibus ut ipsum. Praesent et tellus nibh. Ut tristique at neque vitae viverra. Mauris quis justo sed metus luctus faucibus et non ex. Mauris suscipit, velit nec efficitur pulvinar, metus velit posuere augue, vitae scelerisque mi ex et dui.\n",
"\n",
"Fusce gravida dapibus posuere. Maecenas commodo maximus urna eu facilisis. Suspendisse ultricies bibendum mauris. Aenean accumsan vulputate dui, cursus ultrices turpis malesuada a. Pellentesque aliquet felis nisi, sed aliquet augue ornare at. Cras quis purus a urna accumsan bibendum. Maecenas at turpis est. \n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How is you code feeling today?"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"code_folding": [
5
],
"collapsed": false
},
"outputs": [],
"source": [
"\"\"\"\n",
"count the examine scores from https://github.com/qiwsir/StarterLearningPython/blob/master/2code/20502.py\n",
"\"\"\"\n",
"from __future__ import division\n",
"\n",
"class Scorer: \n",
" def __init__(self):\n",
" pass\n",
" \n",
" def average_score(scores):\n",
" \"\"\"\n",
" count average score.\n",
" \"\"\"\n",
" score_values = scores.values()\n",
" sum_scores = sum(score_values)\n",
" average = sum_scores/len(score_values)\n",
" return average\n",
"\n",
" def sorted_score(scores):\n",
" \"\"\"\n",
" count the list for max to min.\n",
" \"\"\"\n",
" score_lst = [(scores[k],k) for k in scores]\n",
" sort_lst = sorted(score_lst, reverse=True)\n",
" return [(i[1], i[0]) for i in sort_lst]\n",
"\n",
" def max_score(scores):\n",
" \"\"\"\n",
" the max scroe and the person's name.\n",
" \"\"\"\n",
" lst = sorted_score(scores)\n",
" max_score = lst[0][1]\n",
" return [(i[0],i[1]) for i in lst if i[1]==max_score]\n",
"\n",
" def min_score(scores):\n",
" \"\"\"\n",
" the min score and the person's name.\n",
" \"\"\"\n",
" lst = sorted_score(scores)\n",
" min_score = lst[len(lst)-1][1]\n",
" return [(i[0],i[1]) for i in lst if i[1]==min_score]\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Do you get the gist dictionary comprehensions all?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# a dictionary comprehension example using lists\n",
"\n",
"list_keys = ['a', 'b', 'c']\n",
"list_vals = [1, 2, 3]\n",
"\n",
"{a: b for a,b in zip(list_keys, list_vals)}"
]
},
{
"cell_type": "markdown",
"metadata": {
"hide_input": true
},
"source": [
"# Would you like some math?\n",
"\n",
"You can use the normal `$` and `$$` to insert LaTeX math into your document to do pretty things like:\n",
"\n",
"$$\\boldsymbol{\\beta} = (\\beta_1,\\beta_2,\\dotsc,\\beta_n)$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"But what if you want to do numbering of such pretty things?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\\begin{equation}\n",
" \\label{eq:t}\n",
" \\begin{aligned}\n",
" f(x) &= x^2\\\\ \n",
" g(x) &= \\exp(x)\n",
" \\end{aligned}\n",
"\\end{equation}\n",
"\n",
"\\begin{equation}\n",
"\\left(\n",
" \\begin{array}{c}\n",
" n \\\\\n",
" r\n",
" \\end{array}\n",
" \\right) = \\frac{n!}{r!(n-r)!}\n",
"\\end{equation}\n",
"\n",
"\\begin{equation}\n",
"A_{m,n} =\n",
"\\begin{pmatrix}\n",
" a_{1,1} & a_{1,2} & \\cdots & a_{1,n} \\\\\n",
" a_{2,1} & a_{2,2} & \\cdots & a_{2,n} \\\\\n",
" \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
" a_{m,1} & a_{m,2} & \\cdots & a_{m,n} \n",
" \\end{pmatrix}\n",
"\\end{equation}"
]
}
],
"metadata": {
"_draft": {
"nbviewer_url": "https://gist.github.com/9b1ea86ff66d7ea623bda2c751de526a"
},
"anaconda-cloud": {},
"gist": {
"data": {
"description": "example_document.ipynb",
"public": true
},
"id": "9b1ea86ff66d7ea623bda2c751de526a"
},
"kernelspec": {
"display_name": "Python [conda root]",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
},
"toc": {
"nav_menu": {
"height": "142px",
"width": "252px"
},
"navigate_menu": true,
"number_sections": true,
"sideBar": false,
"threshold": 4,
"toc_cell": true,
"toc_position": {
"height": "485px",
"left": "1px",
"right": "856.767px",
"top": "103px",
"width": "212px"
},
"toc_section_display": "none",
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 1
}

+ 485
- 0
nbextensions_talk.ipynb Vedi File

@@ -0,0 +1,485 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Being More Productive with Jupyter Notebooks \n",
"> ## An Introduction to NBExtensions \n",
"\n",
"<br/>\n",
"<br/>\n",
"\n",
"\n",
"#### Keith Maull / NCAR\n",
"#### April 20, 2017"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Jupyter Notebooks\n",
"<img src=\"images/jupyter.jpg\" width=\"360\"/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## ... are awesome.\n",
"\n",
"[![](./images/icedragon_2017-04-20_14-08-19.png)](https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## but if you use Jupyter ... you surely use NBextensions"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## ... or maybe you've _heard of them_\n",
"\n",
"<img src=\"images/firefox_2017-04-20_10-03-00.png\" width=\"800\"/>\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## ... or maybe even _seen_ them lurking ...\n",
"\n",
"<img src=\"images/firefox_2017-04-20_10-06-52_frog.png\" width=\"800\"/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# But have you _really used_ them?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# NBExtensions in 30 seconds ..."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## NBExtensions are to Jupyter Notebooks what plugins are to Chrome"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## They make working <strike>on</strike> in Jupyter fun and interesting"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## ... and they might even make you more productive"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# NB Extensions / How?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## To get started you'll need a few key ingredients ..."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## ingredient 0: a current version of Jupyter!"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## NB Extensions / How? / Installation"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"### if you're using `pip` :\n",
"```\n",
"pip install jupyter_contrib_nbextensions\n",
"```\n",
"\n",
"### if you're using `conda`:\n",
"```\n",
"jupyter contrib nbextension install [--user | --system | ...]\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## NB Extensions / How? / Installation"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"### now check your environment ...\n",
"\n",
"<img src=\"images/firefox_2017-04-20_13-16-38.png\"/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"[![](images/icedragon_2017-04-20_14-11-49.png)](http://localhost:8889/tree#nbextensions_configurator)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Five plugins you should _try today_!"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## 5: [Table of Contents](./example_document.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"hide_input": true,
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## 4: [Code folding](./example_document.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hide_input": false,
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## 3: [Gist-it](./example_document.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## 2: [Equation autonumbering](./example_document.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hide_input": false,
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## 1: [spell checker](./example_document.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## 0: [Nbextensions dashboard tab](./example_document.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"<img src=\"images/parachute-1242426_1920.jpg\" width=\"800\"/>\n",
"<center>\n",
"<h1>Thank you!</h1>\n",
"<h4>Let's collaborate: `kmaull@ucar.edu`</h4>\n",
"</center>"
]
}
],
"metadata": {
"anaconda-cloud": {},
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
},
"nbpresent": {
"slides": {
"bed0ac58-cf34-4f59-9302-6146dff3ab44": {
"id": "bed0ac58-cf34-4f59-9302-6146dff3ab44",
"layout": "manual",
"prev": null,
"regions": {
"d1854d10-660b-4c3a-89a8-70cdb0a724c0": {
"attrs": {
"height": 0.8,
"width": 0.8,
"x": 0.1,
"y": 0.1
},
"id": "d1854d10-660b-4c3a-89a8-70cdb0a724c0"
}
}
}
},
"themes": {
"default": "b802de63-d7e4-4da1-98e4-ee0067e6956a",
"theme": {
"b802de63-d7e4-4da1-98e4-ee0067e6956a": {
"id": "b802de63-d7e4-4da1-98e4-ee0067e6956a",
"palette": {
"19cc588f-0593-49c9-9f4b-e4d7cc113b1c": {
"id": "19cc588f-0593-49c9-9f4b-e4d7cc113b1c",
"rgb": [
252,
252,
252
]
},
"31af15d2-7e15-44c5-ab5e-e04b16a89eff": {
"id": "31af15d2-7e15-44c5-ab5e-e04b16a89eff",
"rgb": [
68,
68,
68
]
},
"50f92c45-a630-455b-aec3-788680ec7410": {
"id": "50f92c45-a630-455b-aec3-788680ec7410",
"rgb": [
155,
177,
192
]
},
"c5cc3653-2ee1-402a-aba2-7caae1da4f6c": {
"id": "c5cc3653-2ee1-402a-aba2-7caae1da4f6c",
"rgb": [
43,
126,
184
]
},
"efa7f048-9acb-414c-8b04-a26811511a21": {
"id": "efa7f048-9acb-414c-8b04-a26811511a21",
"rgb": [
25.118061674008803,
73.60176211453744,
107.4819383259912
]
}
},
"rules": {
"blockquote": {
"color": "50f92c45-a630-455b-aec3-788680ec7410"
},
"code": {
"font-family": "Anonymous Pro"
},
"h1": {
"color": "c5cc3653-2ee1-402a-aba2-7caae1da4f6c",
"font-family": "Lato",
"font-size": 8
},
"h2": {
"color": "c5cc3653-2ee1-402a-aba2-7caae1da4f6c",
"font-family": "Lato",
"font-size": 6
},
"h3": {
"color": "50f92c45-a630-455b-aec3-788680ec7410",
"font-family": "Lato",
"font-size": 5.5
},
"h4": {
"color": "c5cc3653-2ee1-402a-aba2-7caae1da4f6c",
"font-family": "Lato",
"font-size": 5
},
"h5": {
"font-family": "Lato"
},
"h6": {
"font-family": "Lato"
},
"h7": {
"font-family": "Lato"
},
"pre": {
"font-family": "Anonymous Pro",
"font-size": 4
}
},
"text-base": {
"font-family": "Merriweather",
"font-size": 4
}
}
}
}
},
"toc": {
"nav_menu": {
"height": "512px",
"width": "252px"
},
"navigate_menu": true,
"number_sections": false,
"sideBar": true,
"threshold": 4,
"toc_cell": false,
"toc_section_display": "none",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 0
}

+ 12147
- 0
nbextensions_talk.slides.html
File diff soppresso perché troppo grande
Vedi File


Loading…
Annulla
Salva