当前位置: 首页>>代码示例>>Python>>正文


Python Experiment.get_alternative方法代码示例

本文整理汇总了Python中sixpack.models.Experiment.get_alternative方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.get_alternative方法的具体用法?Python Experiment.get_alternative怎么用?Python Experiment.get_alternative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sixpack.models.Experiment的用法示例。


在下文中一共展示了Experiment.get_alternative方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_uniform_choice

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import get_alternative [as 别名]
    def test_uniform_choice(self):

        # test name: deterministic-1
        # client: 09a7407c-e371-492b-82e3-ef438d960ca3
        # num alts: 2
        # salted: deterministic-1.09a7407c-e371-492b-82e3-ef438d960ca3
        # hased: 179d8fdfcd3b4725a112121af37620cca633fbdc
        # first 7: 179d8fd
        # to int: 24762621
        # mod 2: 1
        exp = Experiment('deterministic-1', ['y', 'n'], redis=self.redis)
        cli = SClient('09a7407c-e371-492b-82e3-ef438d960ca3', redis=self.redis)
        alt = exp.get_alternative(cli).name
        self.assertEqual('n', alt)

        # test name: deterministic-1
        # client: 09a7407c-e371-492b-82e3-ef438d960ca3
        # num alts: 3
        # salted: deterministic-1.09a7407c-e371-492b-82e3-ef438d960ca3
        # hased: 179d8fdfcd3b4725a112121af37620cca633fbdc
        # first 7: 179d8fd
        # to int: 24762621
        # mod 3: 1
        exp = Experiment('deterministic-1', ['y', 'n', 'm'], redis=self.redis)
        cli = SClient('09a7407c-e371-492b-82e3-ef438d960ca3', redis=self.redis)
        alt = exp.get_alternative(cli).name
        self.assertEqual('n', alt)

        # test name: deterministic-2
        # client: 1b7b8b69-9b5b-4720-ba08-3e449fd60260
        # num alts: 3
        # salted: deterministic-2.1b7b8b69-9b5b-4720-ba08-3e449fd60260
        # hased: c55c5f029437e37ba830c18810362a3ffaa31538
        # first 7: c55c5f0
        # to int: 206947824
        # mod 3: 0
        exp = Experiment('deterministic-2', ['y', 'n', 'm'], redis=self.redis)
        cli = SClient('1b7b8b69-9b5b-4720-ba08-3e449fd60260', redis=self.redis)
        alt = exp.get_alternative(cli).name
        self.assertEqual('y', alt)

        # test name: deterministic-3
        # client: 53c07ed4-80cd-4860-ad68-7eb76ed27180
        # num alts: 6
        # salted: deterministic-3.53c07ed4-80cd-4860-ad68-7eb76ed27180
        # hased: d802aac8271a522eac4ad596967a5bf3e5696a72
        # first 7: d802aac
        # to int: 226503340
        # mod 6: 4
        exp = Experiment('deterministic-3', ['y', 'n', 'm', 'one', 'two', 'three'], redis=self.redis)
        cli = SClient('53c07ed4-80cd-4860-ad68-7eb76ed27180', redis=self.redis)
        alt = exp.get_alternative(cli).name
        self.assertEqual('two', alt)
开发者ID:BigR-Lab,项目名称:sixpack,代码行数:55,代码来源:alternative_choice_test.py

示例2: test_participate_with_client_chosen_alternative

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import get_alternative [as 别名]
 def test_participate_with_client_chosen_alternative(self, mock_find_or_create):
     exp = Experiment("test", ["no", "yes"], winner=None)
     exp.get_alternative = Mock(return_value=Alternative("yes", exp))
     mock_find_or_create.return_value = exp
     alternative = participate("test", ["no", "yes"], "id1", alternative="yes")
     exp.get_alternative.assert_called_once()
     self.assertEqual("yes", alternative.name)
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:9,代码来源:api_test.py

示例3: test_participate

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import get_alternative [as 别名]
 def test_participate(self, mock_find_or_create):
     exp = Experiment("test", ["no", "yes"], winner=None)
     exp.get_alternative = Mock(return_value=Alternative("yes", exp))
     mock_find_or_create.return_value = exp
     alternative = participate("test", ["no", "yes"], "id1")
     self.assertEqual("yes", alternative.name)
     self.assertEqual("test", alternative.experiment.name)
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:9,代码来源:api_test.py

示例4: test_find_existing_conversion

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import get_alternative [as 别名]
 def test_find_existing_conversion(self):
     exp = Experiment('test-find-existing-conversion', ['1', '2'], redis=self.app.redis)
     client = Client("eric", redis=self.app.redis)
     alt = exp.get_alternative(client)
     exp.convert(client)
     alt2 = exp.existing_conversion(client)
     self.assertIsNotNone(alt2)
     self.assertTrue(alt.name == alt2.name)
     client2 = Client("zack", redis=self.app.redis)
     alt3 = exp.existing_conversion(client2)
     self.assertIsNone(alt3)
开发者ID:BigR-Lab,项目名称:sixpack,代码行数:13,代码来源:experiment_lua_test.py

示例5: test_cant_convert_twice

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import get_alternative [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)
开发者ID:BigR-Lab,项目名称:sixpack,代码行数:18,代码来源:experiment_lua_test.py

示例6: test_cant_convert_twice

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import get_alternative [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"))
开发者ID:desaraev,项目名称:sixpack,代码行数:26,代码来源:experiment_lua_test.py

示例7: test_convert

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import get_alternative [as 别名]
 def test_convert(self):
     exp = Experiment('test-convert', ['1', '2'], redis=self.app.redis)
     client = Client("eric", redis=self.app.redis)
     exp.get_alternative(client)
     exp.convert(client)
     self.assertEqual(exp.total_conversions(), 1)
开发者ID:BigR-Lab,项目名称:sixpack,代码行数:8,代码来源:experiment_lua_test.py


注:本文中的sixpack.models.Experiment.get_alternative方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。