def testPOSIXct_fromPythonTime(self): x = [ time.struct_time(_dateval_tuple), time.struct_time(_dateval_tuple) ] res = robjects.POSIXct(x) self.assertEqual(2, len(x))
def testPOSIXct_fromPythonDatetime(self): x = [ datetime.datetime(*_dateval_tuple[:-2]), datetime.datetime(*_dateval_tuple[:-2]) ] res = robjects.POSIXct(x) self.assertEqual(2, len(x))
def testPOSIXct_fromPythonDatetime(): x = [ datetime.datetime(*_dateval_tuple[:-2]), datetime.datetime(*_dateval_tuple[:-2]) ] res = robjects.POSIXct(x) assert len(x) == 2
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)
def testPOSIXct_fromSexp(self): sexp = robjects.r('ISOdate(2013, 12, 11)') res = robjects.POSIXct(sexp) self.assertEqual(1, len(res))
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
def testPOSIXct_repr(): sexp = robjects.r('ISOdate(2013, 12, 11)') res = robjects.POSIXct(sexp) s = repr(res) assert s.endswith('[2013-12-1...]')
def testPOSIXct_fromSexp(): sexp = robjects.r('ISOdate(2013, 12, 11)') res = robjects.POSIXct(sexp) assert len(res) == 1
def test_POSIXct_from_pythontime(): x = [time.struct_time(_dateval_tuple), time.struct_time(_dateval_tuple)] res = robjects.POSIXct(x) assert len(x) == 2
def test_POSIXct_from_invalidobject(): x = ['abc', 3] with pytest.raises(TypeError): robjects.POSIXct(x)