[IPython-dev] use of InteractiveShell and R magic
MinRK
benjaminrk at gmail.com
Thu Jun 14 18:35:04 EDT 2012
On Thu, Jun 14, 2012 at 3:23 PM, Jonathan Taylor <
jonathan.taylor at stanford.edu> wrote:
> I'm trying to run some cells through InteractiveShell and am getting an
> unexpected error message which is that my shell
> can't find the %R line magic:
>
>
> In [1]: import IPython.frontend.terminal.interactiveshell as IS
>
> In [2]: shell = IS.InteractiveShell()
>
> In [3]: shell.run_cell('%load_ext rmagic')
>
> In [4]: shell.run_cell('%R X=rnorm(20)')
> ERROR: Line magic function `%R` not found.
> In [5]:
>
> In [5]: load_ext rmagic
>
> In [6]: %R X=rnorm(20)
> Out[6]:
> array([ 0.08724969, 2.03344439, -0.82111458, -2.07136391, -0.11913743,
> 0.19598438, 0.58574042, -0.33684877, -0.9659225 , -0.68404775,
> -0.0278716 , 1.34169008, -0.6034878 , 1.76146422, -0.19225874,
> -1.15088263, -1.10644146, -1.27298014, -1.18212805, 1.60194601])
>
> Is this expected? I can't tell.
>
One thing that's not at all expected is creating a new InteractiveShell
inside an InteractiveShell. Do you mean to be creating a whole new
InteractiveShell object in which to run these commands?
If you want a handle on the*existing* shell, you can use: shell =
get_ipython().
If you do that, your run_cell calls above seem to behave as you are
expecting.
-MinRK
>
>
> --
> Jonathan Taylor
> Dept. of Statistics
> Sequoia Hall, 137
> 390 Serra Mall
> Stanford, CA 94305
> Tel: 650.723.9230
> Fax: 650.725.8977
> Web: http://www-stat.stanford.edu/~jtaylo
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20120614/855986ba/attachment.html>
More information about the IPython-dev
mailing list