本文整理汇总了Python中Orange.data.TimeVariable.repr_val方法的典型用法代码示例。如果您正苦于以下问题:Python TimeVariable.repr_val方法的具体用法?Python TimeVariable.repr_val怎么用?Python TimeVariable.repr_val使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.TimeVariable
的用法示例。
在下文中一共展示了TimeVariable.repr_val方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_have_date
# 需要导入模块: from Orange.data import TimeVariable [as 别名]
# 或者: from Orange.data.TimeVariable import repr_val [as 别名]
def test_have_date(self):
var = TimeVariable('time')
ts = var.parse('1937-08-02') # parse date
self.assertEqual(var.repr_val(ts), '1937-08-02')
ts = var.parse('16:20') # parse time
# observe have datetime
self.assertEqual(var.repr_val(ts), '1970-01-01 16:20:00')
示例2: test_parse_utc
# 需要导入模块: from Orange.data import TimeVariable [as 别名]
# 或者: from Orange.data.TimeVariable import repr_val [as 别名]
def test_parse_utc(self):
var = TimeVariable('time')
datestr, offset = '2015-10-18 22:48:20', '+0200'
ts1 = var.parse(datestr + offset)
self.assertEqual(var.repr_val(ts1), datestr + offset)
# Once a value is without a TZ, all the values lose it
ts2 = var.parse(datestr)
self.assertEqual(var.repr_val(ts2), datestr)
self.assertEqual(var.repr_val(ts1), '2015-10-18 20:48:20')
示例3: test_parse_repr
# 需要导入模块: from Orange.data import TimeVariable [as 别名]
# 或者: from Orange.data.TimeVariable import repr_val [as 别名]
def test_parse_repr(self):
for datestr, timestamp, outstr in self.TESTS:
var = TimeVariable('time')
ts = var.to_val(datestr) # calls parse for strings
if not np.isnan(ts):
self.assertEqual(ts, timestamp, msg=datestr)
self.assertEqual(var.repr_val(ts), outstr, msg=datestr)
示例4: test_repr_value
# 需要导入模块: from Orange.data import TimeVariable [as 别名]
# 或者: from Orange.data.TimeVariable import repr_val [as 别名]
def test_repr_value(self):
# https://github.com/biolab/orange3/pull/1760
var = TimeVariable('time')
self.assertEqual(var.repr_val(Value(var, 416.3)), '416.3')
示例5: test_parse_timestamp
# 需要导入模块: from Orange.data import TimeVariable [as 别名]
# 或者: from Orange.data.TimeVariable import repr_val [as 别名]
def test_parse_timestamp(self):
var = TimeVariable("time")
datestr = str(datetime(2016, 6, 14, 23, 8, tzinfo=timezone.utc).timestamp())
ts1 = var.parse(datestr)
self.assertEqual(var.repr_val(ts1), '2016-06-14 23:08:00')
示例6: test_parse_repr
# 需要导入模块: from Orange.data import TimeVariable [as 别名]
# 或者: from Orange.data.TimeVariable import repr_val [as 别名]
def test_parse_repr(self):
for datestr, timestamp, outstr in self.TESTS:
var = TimeVariable('time')
ts = var.parse(datestr)
self.assertEqual(ts, timestamp, msg=datestr)
self.assertEqual(var.repr_val(ts), outstr, msg=datestr)