• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Experiment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_change_alternatives

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

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

        exp.delete()

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


示例17: setUp

    def setUp(self):
        self.redis = fakeredis.FakeStrictRedis()
        self.alternatives = ['yes', 'no']

        self.exp_1 = Experiment('show-something-awesome', self.alternatives, redis=self.redis)
        self.exp_2 = Experiment('dales-lagunitas', ['dales', 'lagunitas'], redis=self.redis)
        self.exp_3 = Experiment('mgd-budheavy', ['mgd', 'bud-heavy'], redis=self.redis)
        self.exp_1.save()
        self.exp_2.save()
        self.exp_3.save()
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:10,代码来源:experiment_model_test.py


示例18: setUp

    def setUp(self):
        self.redis = fakeredis.FakeStrictRedis()
        self.alternatives = ["yes", "no"]

        self.exp_1 = Experiment("show-something-awesome", self.alternatives, self.redis)
        self.exp_2 = Experiment("dales-lagunitas", ["dales", "lagunitas"], self.redis)
        self.exp_3 = Experiment("mgd-budheavy", ["mgd", "bud-heavy"], self.redis)
        self.exp_1.save()
        self.exp_2.save()
        self.exp_3.save()
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:10,代码来源:experiment_model_test.py


示例19: test_key

    def test_key(self):
        key = self.exp_1.key()
        self.assertEqual(key, "sxp:e:show-something-awesome")

        key_2 = self.exp_2.key()
        self.assertEqual(key_2, "sxp:e:dales-lagunitas")

        exp = Experiment("brews", ["mgd", "bud-heavy"], self.redis)
        key_3 = exp.key()
        self.assertEqual(key_3, "sxp:e:brews")
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:10,代码来源:experiment_model_test.py


示例20: _test_initialize_alternatives

    def _test_initialize_alternatives(self):
        # Should throw ValueError
        with self.assertRaises(ValueError):
            Experiment.initialize_alternatives("n", ["*"], self.redis)

        # each item in list should be Alternative Instance
        alt_objs = Experiment.initialize_alternatives("n", ["1", "2", "3"])
        for alt in alt_objs:
            self.assertTrue(isinstance(alt, Alternative))
            self.assertTrue(alt.name in ["1", "2", "3"])
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:10,代码来源:experiment_model_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sk1._函数代码示例发布时间:2022-05-27
下一篇:
Python urllib_parse.urlunparse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap