This file is indexed.

/usr/lib/python3/dist-packages/rpy2/robjects/tests/testFunction.py is in python3-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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import unittest
import rpy2.robjects as robjects
rinterface = robjects.rinterface
import array

identical = rinterface.baseenv["identical"]
Function = robjects.functions.Function
SignatureTranslatedFunction = robjects.functions.SignatureTranslatedFunction

class FunctionTestCase(unittest.TestCase):
    def testNewInvalid(self):
        self.assertRaises(ValueError, Function, 'a')

    def testNewInvalid(self):
        ri_f = rinterface.baseenv.get('help')
        
        ro_f = Function(ri_f)
        
        self.assertTrue(identical(ri_f, ro_f))

    def testCall(self):
        ri_f = rinterface.baseenv.get('sum')
        ro_f = Function(ri_f)
        
        ro_v = robjects.Vector(array.array('i', [1,2,3]))
        
        s = ro_f(ro_v)

    def testCallWithSexp(self):
        ro_f = robjects.baseenv["sum"]
        ri_vec = robjects.rinterface.SexpVector([1,2,3], 
                                                robjects.rinterface.INTSXP)
        res = ro_f(ri_vec)
        self.assertEqual(6, res[0])

    def testCallClosureWithRObject(self):
        ri_f = rinterface.baseenv["sum"]
        ro_vec = robjects.Vector(array.array('i', [1,2,3]))
        res = ri_f(ro_vec)
        self.assertEqual(6, res[0])

    def testFormals(self):
        ri_f = robjects.r('function(x, y) TRUE')
        res = ri_f.formals()
        #FIXME: no need for as.list when paired list are handled
        res = robjects.r['as.list'](res)
        self.assertEqual(2, len(res))
        n = res.names
        self.assertEqual("x", n[0])
        self.assertEqual("y", n[1])

class SignatureTranslatedFunctionTestCase(unittest.TestCase):
    def testNewInvalid(self):
        self.assertRaises(ValueError, 
                          SignatureTranslatedFunction, 'a')

    def testNew(self):
        ri_f = rinterface.baseenv.get('rank')
        ro_f = SignatureTranslatedFunction(ri_f)        
        self.assertTrue(identical(ri_f, ro_f))

    @unittest.expectedFailure
    def testNewWithTranslation(self):
        ri_f = rinterface.baseenv.get('rank')
        ro_f = SignatureTranslatedFunction(ri_f,
                                           prm_translate = {'foo_bar': 'na.last'})
        self.assertTrue(identical(ri_f, ro_f))

    def testCall(self):
        ri_f = rinterface.baseenv.get('sum')
        ro_f = robjects.Function(ri_f)
        
        ro_v = robjects.Vector(array.array('i', [1,2,3]))
        
        s = ro_f(ro_v)

def suite():
    suite = unittest.TestLoader().loadTestsFromTestCase(FunctionTestCase)
    return suite

if __name__ == '__main__':
     unittest.main()