|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": { |
| 6 | + "deletable": true, |
| 7 | + "editable": true |
| 8 | + }, |
| 9 | + "source": [ |
| 10 | + "To run a cell, click on it and use shift-enter:" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "code", |
| 15 | + "execution_count": null, |
| 16 | + "metadata": { |
| 17 | + "collapsed": true, |
| 18 | + "deletable": true, |
| 19 | + "editable": true |
| 20 | + }, |
| 21 | + "outputs": [], |
| 22 | + "source": [ |
| 23 | + "import openpathsampling as paths" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "metadata": {}, |
| 29 | + "source": [ |
| 30 | + "While it is working (which sometimes takes a while for the first cell) you will see a `*`. Once it is done, you'll see a number" |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "markdown", |
| 35 | + "metadata": { |
| 36 | + "deletable": true, |
| 37 | + "editable": true |
| 38 | + }, |
| 39 | + "source": [ |
| 40 | + "If you want a little information about an object, use the `?` operator." |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + "cell_type": "code", |
| 45 | + "execution_count": null, |
| 46 | + "metadata": { |
| 47 | + "collapsed": true, |
| 48 | + "deletable": true, |
| 49 | + "editable": true |
| 50 | + }, |
| 51 | + "outputs": [], |
| 52 | + "source": [ |
| 53 | + "?paths.ShootingPointAnalysis" |
| 54 | + ] |
| 55 | + }, |
| 56 | + { |
| 57 | + "cell_type": "markdown", |
| 58 | + "metadata": { |
| 59 | + "deletable": true, |
| 60 | + "editable": true |
| 61 | + }, |
| 62 | + "source": [ |
| 63 | + "The `?` can come before or after the object:" |
| 64 | + ] |
| 65 | + }, |
| 66 | + { |
| 67 | + "cell_type": "code", |
| 68 | + "execution_count": null, |
| 69 | + "metadata": { |
| 70 | + "collapsed": true, |
| 71 | + "deletable": true, |
| 72 | + "editable": true |
| 73 | + }, |
| 74 | + "outputs": [], |
| 75 | + "source": [ |
| 76 | + "paths.CommittorSimulation?" |
| 77 | + ] |
| 78 | + }, |
| 79 | + { |
| 80 | + "cell_type": "markdown", |
| 81 | + "metadata": { |
| 82 | + "deletable": true, |
| 83 | + "editable": true |
| 84 | + }, |
| 85 | + "source": [ |
| 86 | + "There's also a `help()` function, which gives much more detailed information, including all the inherited methods for a class. Note that this reports in the output, whereas the others pop up a special window. That's because `help` is standard Python, whereas `?` is an IPython extension." |
| 87 | + ] |
| 88 | + }, |
| 89 | + { |
| 90 | + "cell_type": "code", |
| 91 | + "execution_count": null, |
| 92 | + "metadata": { |
| 93 | + "collapsed": false, |
| 94 | + "deletable": true, |
| 95 | + "editable": true |
| 96 | + }, |
| 97 | + "outputs": [], |
| 98 | + "source": [ |
| 99 | + "help(paths.CVDefinedVolume)" |
| 100 | + ] |
| 101 | + }, |
| 102 | + { |
| 103 | + "cell_type": "markdown", |
| 104 | + "metadata": { |
| 105 | + "deletable": true, |
| 106 | + "editable": true |
| 107 | + }, |
| 108 | + "source": [ |
| 109 | + "You can also use the `??` operator to get directly to the code:" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "code", |
| 114 | + "execution_count": null, |
| 115 | + "metadata": { |
| 116 | + "collapsed": true, |
| 117 | + "deletable": true, |
| 118 | + "editable": true |
| 119 | + }, |
| 120 | + "outputs": [], |
| 121 | + "source": [ |
| 122 | + "??paths.PathSampling" |
| 123 | + ] |
| 124 | + }, |
| 125 | + { |
| 126 | + "cell_type": "markdown", |
| 127 | + "metadata": { |
| 128 | + "deletable": true, |
| 129 | + "editable": true |
| 130 | + }, |
| 131 | + "source": [ |
| 132 | + "All of these work with any object (including instances of object) or any method/function. If thing being queried is missing a docstring, then `?` isn't very informative, but you can always see the code with `??`.\n", |
| 133 | + "\n", |
| 134 | + "Also, try using shift-tab while the cursor is inside the word `PathSampling`. This gives a very brief description. Hit shift-tab a second time, and it is like the `?` operator." |
| 135 | + ] |
| 136 | + }, |
| 137 | + { |
| 138 | + "cell_type": "markdown", |
| 139 | + "metadata": { |
| 140 | + "deletable": true, |
| 141 | + "editable": true |
| 142 | + }, |
| 143 | + "source": [ |
| 144 | + "Jupyter notebooks (and IPython) also support tab-completion. This can be a quick way to browse for functions. In the cell below, type `paths.` and hit tab: you'll see a list of the (many) options." |
| 145 | + ] |
| 146 | + }, |
| 147 | + { |
| 148 | + "cell_type": "code", |
| 149 | + "execution_count": null, |
| 150 | + "metadata": { |
| 151 | + "collapsed": true, |
| 152 | + "deletable": true, |
| 153 | + "editable": true |
| 154 | + }, |
| 155 | + "outputs": [], |
| 156 | + "source": [ |
| 157 | + "paths." |
| 158 | + ] |
| 159 | + }, |
| 160 | + { |
| 161 | + "cell_type": "markdown", |
| 162 | + "metadata": {}, |
| 163 | + "source": [ |
| 164 | + "The order in which you execute cells matters, not the order in which the cells occur. For example, if you execute the next cell, you'll get an error:" |
| 165 | + ] |
| 166 | + }, |
| 167 | + { |
| 168 | + "cell_type": "code", |
| 169 | + "execution_count": null, |
| 170 | + "metadata": { |
| 171 | + "collapsed": false |
| 172 | + }, |
| 173 | + "outputs": [], |
| 174 | + "source": [ |
| 175 | + "print message" |
| 176 | + ] |
| 177 | + }, |
| 178 | + { |
| 179 | + "cell_type": "markdown", |
| 180 | + "metadata": {}, |
| 181 | + "source": [ |
| 182 | + "However, if you execute the cell below this, then the cell above it, it will work. Note that the number to the left of the cell changes." |
| 183 | + ] |
| 184 | + }, |
| 185 | + { |
| 186 | + "cell_type": "code", |
| 187 | + "execution_count": null, |
| 188 | + "metadata": { |
| 189 | + "collapsed": true |
| 190 | + }, |
| 191 | + "outputs": [], |
| 192 | + "source": [ |
| 193 | + "message = \"Hello world\"" |
| 194 | + ] |
| 195 | + }, |
| 196 | + { |
| 197 | + "cell_type": "markdown", |
| 198 | + "metadata": { |
| 199 | + "deletable": true, |
| 200 | + "editable": true |
| 201 | + }, |
| 202 | + "source": [ |
| 203 | + "Notebooks are extremely useful for the way they allow you to combine code with text. All the little text I've interleaved here is simply Markdown-formatted. You can change the nature of the cell by going to the Cell -> Cell Type menu.\n", |
| 204 | + "\n", |
| 205 | + "Take the cell below, and change it back and forth between Markdown and Code types. Hit shift-enter to see the Markdown rendered." |
| 206 | + ] |
| 207 | + }, |
| 208 | + { |
| 209 | + "cell_type": "code", |
| 210 | + "execution_count": null, |
| 211 | + "metadata": { |
| 212 | + "collapsed": true, |
| 213 | + "deletable": true, |
| 214 | + "editable": true |
| 215 | + }, |
| 216 | + "outputs": [], |
| 217 | + "source": [ |
| 218 | + "# Shows as comment in code; as header in Markdown. *Italics in Markdown*" |
| 219 | + ] |
| 220 | + }, |
| 221 | + { |
| 222 | + "cell_type": "markdown", |
| 223 | + "metadata": { |
| 224 | + "deletable": true, |
| 225 | + "editable": true |
| 226 | + }, |
| 227 | + "source": [ |
| 228 | + "To learn more about Jupyter, go through the Help menu." |
| 229 | + ] |
| 230 | + } |
| 231 | + ], |
| 232 | + "metadata": { |
| 233 | + "kernelspec": { |
| 234 | + "display_name": "Python 2", |
| 235 | + "language": "python", |
| 236 | + "name": "python2" |
| 237 | + }, |
| 238 | + "language_info": { |
| 239 | + "codemirror_mode": { |
| 240 | + "name": "ipython", |
| 241 | + "version": 2 |
| 242 | + }, |
| 243 | + "file_extension": ".py", |
| 244 | + "mimetype": "text/x-python", |
| 245 | + "name": "python", |
| 246 | + "nbconvert_exporter": "python", |
| 247 | + "pygments_lexer": "ipython2", |
| 248 | + "version": "2.7.13" |
| 249 | + } |
| 250 | + }, |
| 251 | + "nbformat": 4, |
| 252 | + "nbformat_minor": 1 |
| 253 | +} |
0 commit comments