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


Python models.Experiment类代码示例

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


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

示例1: test_created_at

 def test_created_at(self):
     exp = Experiment("bench-press", ["joe", "think"], self.redis)
     date = exp.created_at()
     self.assertIsNone(date)
     exp.save()
     date = exp.created_at()
     self.assertTrue(isinstance(date, datetime))
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例2: test_differing_alternatives_fails

    def test_differing_alternatives_fails(self):
        exp = Experiment.find_or_create('load-differing-alts', ['yes', 'zack', 'PBR'], redis=self.redis)
        alts = Experiment.load_alternatives(exp.name, redis=self.redis)
        self.assertEqual(sorted(alts), sorted(['PBR', 'yes', 'zack']))

        with self.assertRaises(ValueError):
            exp = Experiment.find_or_create('load-differing-alts', ['kyle', 'zack', 'PBR'], redis=self.redis)
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例3: test_valid_traffic_fractions_save

    def test_valid_traffic_fractions_save(self):
        # test the hidden prop gets set
        exp = Experiment.find_or_create('dist-02', ['dist', '100'], traffic_fraction=0.02, redis=self.redis)
        self.assertEqual(exp._traffic_fraction, 0.02)

        exp = Experiment.find_or_create('dist-100', ['dist', '100'], traffic_fraction=0.4, redis=self.redis)
        self.assertEqual(exp._traffic_fraction, 0.40)
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例4: test_invalid_kpi

 def test_invalid_kpi(self):
     ret = Experiment.validate_kpi("!hello-jose")
     self.assertFalse(ret)
     ret = Experiment.validate_kpi("thunder storm")
     self.assertFalse(ret)
     ret = Experiment.validate_kpi("&!&&!&")
     self.assertFalse(ret)
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例5: test_created_at

 def test_created_at(self):
     exp = Experiment('bench-press', ['joe', 'think'], redis=self.redis)
     date = exp.created_at
     self.assertIsNone(date)
     exp.save()
     date = exp.created_at
     self.assertTrue(isinstance(date, datetime))
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例6: test_participate

 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,代码行数:7,代码来源:api_test.py

示例7: test_differing_alternatives_fails

    def test_differing_alternatives_fails(self):
        exp = Experiment.find_or_create("load-differing-alts", ["yes", "zack", "PBR"], self.redis)
        alts = Experiment.load_alternatives(exp.name, self.redis)
        self.assertEqual(sorted(alts), sorted(["PBR", "yes", "zack"]))

        with self.assertRaises(ValueError):
            exp = Experiment.find_or_create("load-differing-alts", ["kyle", "zack", "PBR"], self.redis)
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例8: test_participate_with_client_chosen_alternative

 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,代码行数:7,代码来源:api_test.py

示例9: test_set_winner

    def test_set_winner(self):
        exp = Experiment("test-winner", ["1", "2"], self.redis)
        exp.set_winner("1")
        self.assertTrue(exp.winner is not None)

        exp.set_winner("1")
        self.assertEqual(exp.winner, "1")
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例10: test_convert

 def test_convert(self, mock_find):
     exp = Experiment("test", ["no", "yes"], winner=None)
     exp.convert = Mock(return_value=Alternative("yes", exp))
     mock_find.return_value = exp
     alternative = convert("test", "id1")
     self.assertEqual("yes", alternative.name)
     self.assertEqual("test", alternative.experiment.name)
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:7,代码来源:api_test.py

示例11: test_set_winner

    def test_set_winner(self):
        exp = Experiment('test-winner', ['1', '2'], redis=self.redis)
        exp.set_winner('1')
        self.assertTrue(exp.winner is not None)

        exp.set_winner('1')
        self.assertEqual(exp.winner.name, '1')
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:7,代码来源:experiment_model_test.py

示例12: test_is_control

    def test_is_control(self):
        exp = Experiment("trololo", ["yes", "no"], redis=self.redis)
        exp.save()

        alt = Alternative("yes", exp, redis=self.redis)
        self.assertTrue(alt.is_control())
        exp.delete()
开发者ID:CodeWire,项目名称:sixpack,代码行数:7,代码来源:alternative_model_test.py

示例13: test_convert_with_kpi

 def test_convert_with_kpi(self, mock_find):
     exp = Experiment("test", ["no", "yes"], winner=None)
     exp.convert = Mock(return_value=Alternative("yes", exp))
     mock_find.return_value = exp
     alternative = convert("test", "id1", kpi="goal1")
     # TODO: we're not really asserting anything about the KPI
     self.assertEqual("yes", alternative.name)
     self.assertEqual("test", alternative.experiment.name)
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:8,代码来源:api_test.py

示例14: test_change_alternatives

    def test_change_alternatives(self):
        exp = Experiment.find_or_create("never-gonna-x", ["let", "you", "down"], self.redis)

        with self.assertRaises(ValueError):
            Experiment.find_or_create("never-gonna-x", ["let", "you", "down", "give", "you", "up"], self.redis)

        exp.delete()

        Experiment.find_or_create("never-gonna-x", ["let", "you", "down", "give", "you", "up"], self.redis)
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:9,代码来源:experiment_model_test.py

示例15: test_valid_traffic_fractions_save

    def test_valid_traffic_fractions_save(self):
        # test the hidden prop gets set
        opts = {'traffic_fraction': 0.02}
        exp = Experiment.find_or_create('dist-02', ['dist', '100'], self.redis, opts)
        self.assertEqual(exp._traffic_fraction, 0.02)

        opts = {'traffic_fraction': 0.4}
        exp = Experiment.find_or_create('dist-100', ['dist', '100'], self.redis, opts)
        self.assertEqual(exp._traffic_fraction, 0.40)
开发者ID:metricle,项目名称:sixpack,代码行数:9,代码来源:experiment_model_test.py


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