Пример #1
0
 def testPOSIXct_fromPythonTime(self):
     x = [
         time.struct_time(_dateval_tuple),
         time.struct_time(_dateval_tuple)
     ]
     res = robjects.POSIXct(x)
     self.assertEqual(2, len(x))
Пример #2
0
 def testPOSIXct_fromPythonDatetime(self):
     x = [
         datetime.datetime(*_dateval_tuple[:-2]),
         datetime.datetime(*_dateval_tuple[:-2])
     ]
     res = robjects.POSIXct(x)
     self.assertEqual(2, len(x))
Пример #3
0
def testPOSIXct_fromPythonDatetime():
    x = [
        datetime.datetime(*_dateval_tuple[:-2]),
        datetime.datetime(*_dateval_tuple[:-2])
    ]
    res = robjects.POSIXct(x)
    assert len(x) == 2
Пример #4
0
def test_POSIXct_from_invalidpythontime():
    x = [time.struct_time(_dateval_tuple), 
         time.struct_time(_dateval_tuple)]
    x.append('foo')
    # string 'foo' does not have attribute 'tm_zone'  
    with pytest.raises(AttributeError):
        robjects.POSIXct(x)
Пример #5
0
 def testPOSIXct_fromSexp(self):
     sexp = robjects.r('ISOdate(2013, 12, 11)')
     res = robjects.POSIXct(sexp)
     self.assertEqual(1, len(res))
Пример #6
0
def testPOSIXct_getitem():
    dt = (datetime.datetime(2014, 12, 11) -
          datetime.datetime(1970, 1, 1)).total_seconds()
    sexp = robjects.r('ISOdate(c(2013, 2014), 12, 11, hour = 0, tz = "UTC")')
    res = robjects.POSIXct(sexp)
    assert (res[1] - dt) == 0
Пример #7
0
def testPOSIXct_repr():
    sexp = robjects.r('ISOdate(2013, 12, 11)')
    res = robjects.POSIXct(sexp)
    s = repr(res)
    assert s.endswith('[2013-12-1...]')
Пример #8
0
def testPOSIXct_fromSexp():
    sexp = robjects.r('ISOdate(2013, 12, 11)')
    res = robjects.POSIXct(sexp)
    assert len(res) == 1
Пример #9
0
def test_POSIXct_from_pythontime():
    x = [time.struct_time(_dateval_tuple), time.struct_time(_dateval_tuple)]
    res = robjects.POSIXct(x)
    assert len(x) == 2
Пример #10
0
def test_POSIXct_from_invalidobject():
    x = ['abc', 3]
    with pytest.raises(TypeError):
        robjects.POSIXct(x)