/usr/lib/python2.7/dist-packages/rpy2/robjects/lib/tests/test_ggplot2.py is in python-rpy2 2.8.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | import unittest
# Try to load R ggplot package, and see if it works
from rpy2.rinterface import RRuntimeError
has_ggplot = True
try:
from rpy2.robjects.lib import ggplot2
except RRuntimeError:
has_ggplot = False
from rpy2.robjects.packages import importr
datasets = importr('datasets')
mtcars = datasets.__rdata__.fetch('mtcars')['mtcars']
@unittest.skipUnless(has_ggplot, 'ggplot2 package not available in R')
class GGPlot2TestCase(unittest.TestCase):
def testSetup(self):
pass
def tearDown(self):
pass
def testGGPlot(self):
gp = ggplot2.ggplot(mtcars)
self.assertTrue(isinstance(gp, ggplot2.GGPlot))
def testAdd(self):
gp = ggplot2.ggplot(mtcars)
pp = gp + \
ggplot2.aes_string(x='wt', y='mpg') + \
ggplot2.geom_point()
self.assertTrue(isinstance(pp, ggplot2.GGPlot))
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(GGPlot2TestCase)
return suite
if __name__ == '__main__':
unittest.main()
|