本文整理汇总了Python中sixpack.models.Experiment.objectify_by_period方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.objectify_by_period方法的具体用法?Python Experiment.objectify_by_period怎么用?Python Experiment.objectify_by_period使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sixpack.models.Experiment
的用法示例。
在下文中一共展示了Experiment.objectify_by_period方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cant_convert_twice
# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import objectify_by_period [as 别名]
def test_cant_convert_twice(self):
exp = Experiment('test-cant-convert-twice', ['1', '2'], redis=self.app.redis)
client = Client("eric", redis=self.app.redis)
alt = exp.get_alternative(client)
exp.convert(client)
self.assertEqual(exp.total_conversions(), 1)
exp.convert(client, dt=dateutil.parser.parse("2012-01-01"))
self.assertEqual(exp.total_conversions(), 1)
data = exp.objectify_by_period("day")
altdata = [a for a in data["alternatives"] if a["name"] == alt.name][0]["data"]
total_participants = sum([d["participants"] for d in altdata])
self.assertEqual(total_participants, 1)
total_conversions = sum([d["conversions"] for d in altdata])
self.assertEqual(data["has_winner"], False)
self.assertEqual(total_conversions, 1)
# Only retrieve the slim set.
data = exp.objectify_by_period("day", slim=True)
self.assertFalse(data.has_key("has_winner"))
self.assertFalse(data.has_key("kpi"))
self.assertFalse(data.has_key("kpis"))
self.assertFalse(data.has_key("period"))
示例2: test_cant_convert_twice
# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import objectify_by_period [as 别名]
def test_cant_convert_twice(self):
exp = Experiment('test-cant-convert-twice', ['1', '2'], redis=self.app.redis)
client = Client("eric", redis=self.app.redis)
alt = exp.get_alternative(client)
exp.convert(client)
self.assertEqual(exp.total_conversions(), 1)
exp.convert(client, dt=dateutil.parser.parse("2012-01-01"))
self.assertEqual(exp.total_conversions(), 1)
data = exp.objectify_by_period("day")
altdata = [a for a in data["alternatives"] if a["name"] == alt.name][0]["data"]
total_participants = sum([d["participants"] for d in altdata])
self.assertEqual(total_participants, 1)
total_conversions = sum([d["conversions"] for d in altdata])
self.assertEqual(total_conversions, 1)