Permalink
Browse files

Fix issue #2550

  • Loading branch information...
1 parent ca39815 commit 3632cfbade2e01ca52e7e1dd5323800dcb0b427e @rmcgibbo rmcgibbo committed with Dec 18, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 IPython/extensions/rmagic.py
@@ -178,8 +178,9 @@ def flush(self):
return value
@skip_doctest
+ @needs_local_scope
@line_magic
- def Rpush(self, line):
+ def Rpush(self, line, local_ns=None):
'''
A line-level magic for R that pushes
variables from python to rpy2. The line should be made up
@@ -199,10 +200,16 @@ def Rpush(self, line):
Out[11]: array([ 6.23333333])
'''
+ if local_ns is None:
+ local_ns = {}
inputs = line.split(' ')
for input in inputs:
- self.r.assign(input, self.pyconverter(self.shell.user_ns[input]))
+ try:
+ val = local_ns[input]
+ except KeyError:
+ val = self.shell.user_ns[input]
+ self.r.assign(input, self.pyconverter(val))
@skip_doctest
@magic_arguments()

0 comments on commit 3632cfb

Please sign in to comment.