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
2
votes
1 answer

IPython - importing/populating namespace with custom magic

The %pylab magic in IPython imports a bunch of functions into the user's workspace, which is very convenient. Looking at the code, it's not at all obvious how this is done. What I have so far is a magic function in my startup folder: from…
Peter
  • 12,274
  • 9
  • 71
  • 86
2
votes
0 answers

R magics not working in IPython notebook

Issue with Rmagics in IPython Notebook: %load_ext rpy2.ipython import numpy as np A = np.arange(20) %R -i A %R mean(A) returns the the error: AttributeError: 'numpy.ndarray' object has no attribute 'typeof' when I use %load_ext rmagic in place…
EJ789
  • 21
  • 2
2
votes
0 answers

IPython's %edit Locks Temp File

When using IPython, I try and type in a multi-line code snippet using the %edit "magic function". I'm using the default settings for IPython and I'm on Windows 7, so this brings up Notepad. However, when I try to save the file when I'm done typing,…
Yiab
  • 21
  • 1
2
votes
2 answers

Magic function `bash ` not found

I have a bunch of simulations that I want to run on a high-performance cluster, on which I should make reservations to get computing time. Since the reservations are bounded by time, I am developing an automation script that I can scp into the…
inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241
2
votes
1 answer

Can't execute function specified through %paste%

Is it possible to run a function that is specified by using the magic %paste% function in IPython? In [1]: %paste% def add_to_index(index,keyword,url): for e in index: if e[0] == keyword: if url not in e[1]: …
codingknob
  • 11,108
  • 25
  • 89
  • 126
1
vote
0 answers

Create a custom magic in a Glue Studio Notebook

I've been trying to create custom magic for a Glue Studio Notebook, like the following example (taken from here) I've adding the Ipython module by running the glue magic %additional_python_modules IPython And running this from a cell: from…
1
vote
1 answer

How to run an IPython CELL magic from a script (%% magic)

Jupyter magic commands (starting with a single %, e.g. %timeit) can be run in a script using the answer from How to run an IPython magic from a script (or timing a Python script) However, I cannot find an answer on how to run cell magic commands,…
ntg
  • 12,950
  • 7
  • 74
  • 95
1
vote
1 answer

Stop the effect of %matplotlib notebook in Jupyter notebook

I used the magic commands %matplotlib notebook at some ceil in my notebook to animate some scatter plots. However, after that ceil, I want to remove the effect of this magic command. Anyone has any idea of how to do this?
1
vote
0 answers

A way to use the declared C++ function in Ipython with cpp magic?

In Ipython can someone use a FORTRAN function in python code,with this way: %load_ext fortranmagic %%fortran subroutine f1(x, z) real, intent(in) :: x real, intent(out) :: z integer :: i do i=1,10000 z = 1000*sin(x+i) …
1
vote
0 answers

Define a IPython magic which replace and "update" the content of the next cell

Let's say I have [cell 1] following notebook (I know that could also import this ipython-magic from ~/.ipython/profile_default/startup/: [cell 1] from IPython.display import display, HTML, Javascript from IPython.core.magic import Magics,…
1
vote
0 answers

Is there a way to get only custom registered magics list but not all magic links ( %lsmagic ) in Jupyter notebook / python?

There is magic link "%lsmagic" to list all available magic links, I want to list only custom registered magic links. Is there any way to list only custom magic links?
veeresh patil
  • 1,168
  • 1
  • 11
  • 18
1
vote
0 answers

IPython Scrolling Issue With magic('clear') | Spyder

When running the code below on Spyder, part of the code shown on the IPython console disappears (i.e. it auto scrolls too far down) get_ipython().magic('clear') for i in range(10): print(i) But it doesn't happen when I add…
Mike
  • 102
  • 6
1
vote
1 answer

IPython shortcut for importing pytest fixtures

Suppose that I am writing a test called test_this_thing in IPython which I intend to progressively save into a test file test_some_tests.py. When it comes to running my tests I can do that easily from IPython with this great suggestion from a…
Robert
  • 1,530
  • 1
  • 16
  • 24
1
vote
0 answers

Ipython - persistent variables between sessions

I would like to be able to use python in a way that I can save a session with the data, load it up and carry on with the variables that were in memory. Some of the variables can be fairly large (~1GB), so I would rather not have to read them from…
baxx
  • 3,956
  • 6
  • 37
  • 75
1
vote
1 answer

How to give alias name to commands in jupyter notebook?

I want to give an alias to a command in jupyter notebook such that if i write: Get me list of all students this alias name will call a command that I have written and show the desired result Please help.