Questions tagged [ipython-magic]

A set of pre-defined "magic functions" of IPython that used with the command-line syntax.

A set of pre-defined "magic functions" of that used with the command-line syntax. There are two types of magic functions line-oriented and cell-oriented. The lines start with a magic % and executed from the command line. They get into an argument the rest of the line, where the arguments are passed without parentheses and quotation marks. Cell magic begins with the double %%, and they are functions that get in an argument not only the rest of the line, but the line below it in a separate argument.

169 questions
0
votes
1 answer

Is there a way to make an IPython Notebook output interactivly create an input and execute it?

I was wondering if I can make an output interactively run a piece of code. So if for example I had a class (parts in pseudo-code): import numpy as np class test(object): def __init__(): self.a = np.random.randn(10) print ##…
user4290866
0
votes
1 answer

Install pymatbridge on Windows

I am trying to use pymatbridge. I am using python 2.7.9 64 bits on Windows and Canopy 1.5.5 and when I put the following code in ipython notebook from pymatbridge import Matlab mlab = Matlab(executable='matlab') mlab.start() I receive this…
Mauro
  • 237
  • 6
  • 13
0
votes
1 answer

Extensions Vs Kernels in IPython

In Jupyter, kernels provide support for different languages we want to use in the notebook (such as IRkernel). How is this different from using the magics to write in other languages (%load_ext rmagic and using %%R throughout the code)?
Ethan
  • 55
  • 2
0
votes
1 answer

How to run shell-commands in IPython? (Python Profiling GUI tools)

I am trying to do file profiling in IPython, generate some profiling stats output and then pass it to some Python profiling GUI tools like KCachegrind. Here is my code trying to do that. All codes are executed in IPython. # example function for…
Jianxun Li
  • 24,004
  • 10
  • 58
  • 76
0
votes
0 answers

Ipython magic that replaces some text and runs the cell afterwards

I'm trying to create an ipython magic somewhat akin to the %pylab, but more explicit (probably a follow-up from here ): When run, it would ideally replace itself with a commented version + append the lines that do the imports and run the…
0
votes
0 answers

IPython cell magic with multiple display object types

I would like to create a cell magic in IPython that can return more than one DisplayObject as its result. Specifically, it should return some HTML in the notebook, but I also want a text/python output so that if the notebook is save as Python there…
Graham Wheeler
  • 2,734
  • 1
  • 19
  • 23
0
votes
2 answers

How to save an ipython session if i used magic %paste ? (magic %save doesn't work)

It's seems a fairly simple question but I didn't manage to correctly save my ipython session using magic "%save" If i use the magic "%paste" at any time during the session, saving the session results in this output :…
cyrilV
  • 1
0
votes
1 answer

Getting r data.frame in IPython notebook

I can get data.frame object when using IPython from the command line like this: In [1]: import pandas as pd In [2]: df = pd.DataFrame({'a':[1,2,3],'b':[2,4,6]}) In [3]: df Out[3]: a b 0 1 2 1 2 4 2 3 6 In [4]: %load_ext rmagic In…
Vasco
  • 395
  • 2
  • 13
0
votes
1 answer

Python3 "magic functions" stack trace

I find myself in a situation where I am redefining a lot of the so called "magic" attributes or functions of my class in Python3 (__add__, __sub__, etc.) For all of these, I implement the same two lines of code: arg1 = self.decimal if…
Jeremy
  • 1,717
  • 5
  • 30
  • 49
0
votes
1 answer

ipython %bookmark error: quotes don't fix this

This is probably a stupid question, but I can't find an answer. %bookmark dl 'C:/Users/user1/Downloads' works, but %bookmark md 'C:/Users/user1/my documents' doesn't work, throwing error: "UsageError: %bookmark: too many arguments" How to fix this?
MichM
  • 886
  • 1
  • 12
  • 28
0
votes
1 answer

Is there a way to add timing by default to ipython?

When using IPython, it's often convenient to see how long your commands take to run by using the %time magic function. When you use this often enough, you start to wish that you could just get toggle a setting to get this metadata by default…
RussellStewart
  • 5,293
  • 3
  • 26
  • 23
0
votes
1 answer

Newlines in Function Definition for iPython Terminal

Using %paste, iPython takes newline characters in my function definition as the end of the function. This isn't an issue when I code from someone else's machine. I've looked through the config documentation and other sites; no luck. def…
0
votes
1 answer

When an ipython console connect to an existing kernel linked to a notebook, %load magic can not load code into console

I learned this trick from Using IPython console along side IPython notebook . But when I connect this kernel using console, the %load magic will load file into a pager (like you you do 'man thecodefile.py' in console), not to the input line. Anyone…
NathaneilCapital
  • 1,389
  • 5
  • 17
  • 23
0
votes
1 answer

retrieving python variables from Cell Magic in Ipython notebook from background subprocess

I'm trying to do a quick and dirty querying of my mongodb database using ipython notebook. I have several cells each with its own query. Since mongodb can support several connections I would like to run each query in parallel. I thought an ideal way…
jwillis0720
  • 4,329
  • 8
  • 41
  • 74
0
votes
1 answer

Missing Ipython Cell Magics

In an ipython notebook when I run %lsmagic I get: Available cell magics: %%! %%bash %%capture %%file %%perl %%prun %%python3 %%ruby %%script %%sh %%sx %%system %%timeit I'm expecting to see: Available cell magics: %%! %%HTML %%SVG …
user2356809
1 2 3
11
12