Print information about the magic function system. Supported formats: -latex, -brief, -rest
(self, parameter_s='')
| 207 | |
| 208 | @line_magic |
| 209 | def magic(self, parameter_s=''): |
| 210 | """Print information about the magic function system. |
| 211 | |
| 212 | Supported formats: -latex, -brief, -rest |
| 213 | """ |
| 214 | |
| 215 | mode = '' |
| 216 | try: |
| 217 | mode = parameter_s.split()[0][1:] |
| 218 | except IndexError: |
| 219 | pass |
| 220 | |
| 221 | brief = (mode == 'brief') |
| 222 | rest = (mode == 'rest') |
| 223 | magic_docs = self._magic_docs(brief, rest) |
| 224 | |
| 225 | if mode == 'latex': |
| 226 | print(self.format_latex(magic_docs)) |
| 227 | return |
| 228 | else: |
| 229 | magic_docs = format_screen(magic_docs) |
| 230 | |
| 231 | out = [""" |
| 232 | IPython's 'magic' functions |
| 233 | =========================== |
| 234 | |
| 235 | The magic function system provides a series of functions which allow you to |
| 236 | control the behavior of IPython itself, plus a lot of system-type |
| 237 | features. There are two kinds of magics, line-oriented and cell-oriented. |
| 238 | |
| 239 | Line magics are prefixed with the % character and work much like OS |
| 240 | command-line calls: they get as an argument the rest of the line, where |
| 241 | arguments are passed without parentheses or quotes. For example, this will |
| 242 | time the given statement:: |
| 243 | |
| 244 | %timeit range(1000) |
| 245 | |
| 246 | Cell magics are prefixed with a double %%, and they are functions that get as |
| 247 | an argument not only the rest of the line, but also the lines below it in a |
| 248 | separate argument. These magics are called with two arguments: the rest of the |
| 249 | call line and the body of the cell, consisting of the lines below the first. |
| 250 | For example:: |
| 251 | |
| 252 | %%timeit x = numpy.random.randn((100, 100)) |
| 253 | numpy.linalg.svd(x) |
| 254 | |
| 255 | will time the execution of the numpy svd routine, running the assignment of x |
| 256 | as part of the setup phase, which is not timed. |
| 257 | |
| 258 | In a line-oriented client (the terminal or Qt console IPython), starting a new |
| 259 | input with %% will automatically enter cell mode, and IPython will continue |
| 260 | reading input until a blank line is given. In the notebook, simply type the |
| 261 | whole cell as one entity, but keep in mind that the %% escape can only be at |
| 262 | the very start of the cell. |
| 263 | |
| 264 | NOTE: If you have 'automagic' enabled (via the command line option or with the |
| 265 | %automagic function), you don't need to type in the % explicitly for line |
| 266 | magics; cell magics always require an explicit '%%' escape. By default, |
nothing calls this directly
no test coverage detected