##// END OF EJS Templates
Merge branch 'fix-rmagic'
Thomas Kluyver -
r9008:e3f3a0c9 merge
parent child Browse files
Show More
@@ -337,10 +337,14 b' class RMagics(Magics):'
337 help='Convert these objects to data.frames and return as structured arrays.'
337 help='Convert these objects to data.frames and return as structured arrays.'
338 )
338 )
339 @argument(
339 @argument(
340 '-u', '--units', type=int,
340 '-u', '--units', type=unicode, choices=["px", "in", "cm", "mm"],
341 help='Units of png plotting device sent as an argument to *png* in R. One of ["px", "in", "cm", "mm"].'
341 help='Units of png plotting device sent as an argument to *png* in R. One of ["px", "in", "cm", "mm"].'
342 )
342 )
343 @argument(
343 @argument(
344 '-r', '--res', type=int,
345 help='Resolution of png plotting device sent as an argument to *png* in R. Defaults to 72 if *units* is one of ["in", "cm", "mm"].'
346 )
347 @argument(
344 '-p', '--pointsize', type=int,
348 '-p', '--pointsize', type=int,
345 help='Pointsize of png plotting device sent as an argument to *png* in R.'
349 help='Pointsize of png plotting device sent as an argument to *png* in R.'
346 )
350 )
@@ -524,7 +528,12 b' class RMagics(Magics):'
524 raise NameError("name '%s' is not defined" % input)
528 raise NameError("name '%s' is not defined" % input)
525 self.r.assign(input, self.pyconverter(val))
529 self.r.assign(input, self.pyconverter(val))
526
530
527 png_argdict = dict([(n, getattr(args, n)) for n in ['units', 'height', 'width', 'bg', 'pointsize']])
531 if getattr(args, 'units') is not None:
532 if args.units != "px" and getattr(args, 'res') is None:
533 args.res = 72
534 args.units = '"%s"' % args.units
535
536 png_argdict = dict([(n, getattr(args, n)) for n in ['units', 'res', 'height', 'width', 'bg', 'pointsize']])
528 png_args = ','.join(['%s=%s' % (o,v) for o, v in png_argdict.items() if v is not None])
537 png_args = ','.join(['%s=%s' % (o,v) for o, v in png_argdict.items() if v is not None])
529 # execute the R code in a temporary directory
538 # execute the R code in a temporary directory
530
539
@@ -71,7 +71,7 b' def test_cell_magic():'
71 r = resid(a)
71 r = resid(a)
72 xc = coef(a)
72 xc = coef(a)
73 '''
73 '''
74 ip.run_cell_magic('R', '-i x,y -o r,xc a=lm(y~x)', snippet)
74 ip.run_cell_magic('R', '-i x,y -o r,xc -w 150 -u mm a=lm(y~x)', snippet)
75 np.testing.assert_almost_equal(ip.user_ns['xc'], [3.2, 0.9])
75 np.testing.assert_almost_equal(ip.user_ns['xc'], [3.2, 0.9])
76 np.testing.assert_almost_equal(ip.user_ns['r'], np.array([-0.2, 0.9, -1. , 0.1, 0.2]))
76 np.testing.assert_almost_equal(ip.user_ns['r'], np.array([-0.2, 0.9, -1. , 0.1, 0.2]))
77
77
General Comments 0
You need to be logged in to leave comments. Login now