本文整理匯總了Python中auvsi_suas.models.AccessLog.rates方法的典型用法代碼示例。如果您正苦於以下問題:Python AccessLog.rates方法的具體用法?Python AccessLog.rates怎麽用?Python AccessLog.rates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類auvsi_suas.models.AccessLog
的用法示例。
在下文中一共展示了AccessLog.rates方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_no_data
# 需要導入模塊: from auvsi_suas.models import AccessLog [as 別名]
# 或者: from auvsi_suas.models.AccessLog import rates [as 別名]
def test_no_data(self):
logs = AccessLog.by_user(self.user1)
self.assertEqual(len(logs), 0)
logs = AccessLog.by_time_period(self.user1, [])
self.assertEqual(len(logs), 0)
log_rates = AccessLog.rates(self.user1, [])
self.assertTupleEqual(log_rates, (None, None))
示例2: test_ignore_start_end
# 需要導入模塊: from auvsi_suas.models import AccessLog [as 別名]
# 或者: from auvsi_suas.models.AccessLog import rates [as 別名]
def test_ignore_start_end(self):
"""When start and end are None, only times between logs are compared."""
delta = datetime.timedelta(seconds=1)
logs = self.create_logs(self.user1, delta=delta)
period = TimePeriod(None, None)
rates = AccessLog.rates(self.user1, [period])
self.assertSequenceEqual((1, 1), rates)
示例3: test_constant_rate
# 需要導入模塊: from auvsi_suas.models import AccessLog [as 別名]
# 或者: from auvsi_suas.models.AccessLog import rates [as 別名]
def test_constant_rate(self):
"""Rates computed correctly."""
delta = datetime.timedelta(seconds=1)
logs = self.create_logs(self.user1, delta=delta)
period = self.consistent_period(logs, delta)
rates = AccessLog.rates(self.user1, [period])
self.assertSequenceEqual((1, 1), rates)
示例4: test_provided_logs
# 需要導入模塊: from auvsi_suas.models import AccessLog [as 別名]
# 或者: from auvsi_suas.models.AccessLog import rates [as 別名]
def test_provided_logs(self):
"""Rates computed with provided logs."""
delta = datetime.timedelta(seconds=1)
used_logs = self.create_logs(self.user1, delta=delta)
unused_logs = self.create_logs(self.user1, delta=delta)
period = self.consistent_period(used_logs, delta)
rates = AccessLog.rates(self.user1, [period],
time_period_logs=[used_logs])
self.assertSequenceEqual((1, 1), rates)
示例5: test_multiple_periods
# 需要導入模塊: from auvsi_suas.models import AccessLog [as 別名]
# 或者: from auvsi_suas.models.AccessLog import rates [as 別名]
def test_multiple_periods(self):
"""Multiple periods are combined without introducing errors."""
delta = datetime.timedelta(seconds=1)
logs = [
self.create_logs(self.user1,
start=self.year2000,
delta=delta),
self.create_logs(self.user1,
start=self.year2001,
delta=delta),
]
periods = [self.consistent_period(l, delta) for l in logs]
rates = AccessLog.rates(self.user1, periods)
self.assertSequenceEqual((1, 1), rates)
示例6: test_different_deltas
# 需要導入模塊: from auvsi_suas.models import AccessLog [as 別名]
# 或者: from auvsi_suas.models.AccessLog import rates [as 別名]
def test_different_deltas(self):
"""Sets of logs are combined for overall rates."""
delta = datetime.timedelta(seconds=1)
logs = [
self.create_logs(self.user1,
num=1000,
start=self.year2000,
delta=delta),
self.create_logs(self.user1,
num=1000,
start=self.year2001,
delta=delta / 2),
]
periods = [self.consistent_period(l, delta) for l in logs]
rates = AccessLog.rates(self.user1, periods)
self.assertAlmostEqual(1.0, rates[0]) # max
self.assertAlmostEqual(0.75, rates[1], delta=0.001) # avg