Example #1
0
def numpy2ro(o):
    if isinstance(o, numpy.ndarray):
        res = numpy2ri(o)
        res = ro.vectors.rtypeof2rotype[res.typeof](res)
    else:
        res = ro.default_py2ro(o)
    return res
Example #2
0
def numpy2ro(o):
    if isinstance(o, numpy.ndarray):
        res = numpy2ri(o)
        res = ro.vectors.rtypeof2rotype[res.typeof](res)
    else:
        res = ro.default_py2ro(o)
    return res
 def testMapperPy2R_taggedlist(self):
     py = robjects.rlc.TaggedList(('a', 'b'),
                                  tags=('foo', 'bar'))
     robj = robjects.default_py2ro(py)
     self.assertTrue(isinstance(robj, robjects.Vector))
     self.assertEqual(2, len(robj))
     self.assertEqual(('foo', 'bar'),
                      tuple(robj.names))
 def testMapperPy2R_float(self):
     py = 1.0
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEquals(rinterface.REALSXP, rob.typeof)
 def testMapperPy2R_unicode(self):        
     py = u'houba'
     self.assertTrue(isinstance(py, unicode))
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEquals(rinterface.STRSXP, rob.typeof)
 def testMapperPy2R_boolean(self):        
     py = True
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEquals(rinterface.LGLSXP, rob.typeof)
 def testMapperPy2R_integer(self):
     py = 1
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEquals(rinterface.INTSXP, rob.typeof)
 def testMapperPy2R_complex(self):
     py = 1.0 + 2j
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEquals(rinterface.CPLXSXP, rob.typeof)
Example #9
0
 def testMapperPy2R_complex(self):
     py = 1.0 + 2j
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEqual(rinterface.CPLXSXP, rob.typeof)
Example #10
0
 def testMapperPy2R_float(self):
     py = 1.0
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEqual(rinterface.REALSXP, rob.typeof)
Example #11
0
 def testMapperPy2R_unicode(self):
     py = u'houba'
     self.assertTrue(isinstance(py, unicode))
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEqual(rinterface.STRSXP, rob.typeof)
Example #12
0
 def testMapperPy2R_boolean(self):
     py = True
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEqual(rinterface.LGLSXP, rob.typeof)
Example #13
0
 def testMapperPy2R_integer(self):
     py = 1
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEqual(rinterface.INTSXP, rob.typeof)
Example #14
0
 def testMapperPy2R_str(self):        
     py = 'houba'
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEqual(rinterface.STRSXP, rob.typeof)
Example #15
0
 def testMapperPy2R_py3bytes(self):
     py = b'houba'
     rob = robjects.default_py2ro(py)
     self.assertTrue(isinstance(rob, robjects.Vector))
     self.assertEqual(rinterface.STRSXP, rob.typeof)
Example #16
0
 def testMapperPy2R_taggedlist(self):
     py = robjects.rlc.TaggedList(('a', 'b'), tags=('foo', 'bar'))
     robj = robjects.default_py2ro(py)
     self.assertTrue(isinstance(robj, robjects.Vector))
     self.assertEqual(2, len(robj))
     self.assertEqual(('foo', 'bar'), tuple(robj.names))