コード例 #1
0
ファイル: test_scoresheet.py プロジェクト: royshan/linkpred
class TestBaseScoresheet:
    def setup(self):
        self.scoresheet = BaseScoresheet(
            zip("abcdefghijklmnopqrstuvwx", range(24)))

    def test_ranked_items(self):
        d = dict(self.scoresheet.ranked_items())
        assert_dict_equal(d, dict(self.scoresheet))

        s = self.scoresheet.ranked_items()
        assert_equal(s.next(), ('x', 23))
        assert_equal(s.next(), ('w', 22))
        assert_equal(s.next(), ('v', 21))

    def test_sets_with_threshold(self):
        threshold = 12
        d = dict(self.scoresheet.ranked_items(threshold=threshold))
        assert_dict_equal(d, dict(zip("xwvutsrqponm", reversed(range(12,
                                                                     24)))))

    def test_with_too_large_threshold(self):
        threshold = 25
        for s in self.scoresheet.ranked_items(threshold=threshold):
            assert_less(len(s), threshold)

    def test_top(self):
        top = self.scoresheet.top()
        assert_dict_equal(top, dict(zip("opqrstuvwx", range(14, 24))))

        top = self.scoresheet.top(2)
        assert_dict_equal(top, dict(zip("wx", range(22, 24))))

        top = self.scoresheet.top(100)
        assert_equal(len(top), 24)
コード例 #2
0
ファイル: test_scoresheet.py プロジェクト: royshan/linkpred
class TestBaseScoresheet:
    def setup(self):
        self.scoresheet = BaseScoresheet(
            zip("abcdefghijklmnopqrstuvwx", range(24)))

    def test_ranked_items(self):
        d = dict(self.scoresheet.ranked_items())
        assert_dict_equal(d, dict(self.scoresheet))

        s = self.scoresheet.ranked_items()
        assert_equal(s.next(), ('x', 23))
        assert_equal(s.next(), ('w', 22))
        assert_equal(s.next(), ('v', 21))

    def test_sets_with_threshold(self):
        threshold = 12
        d = dict(self.scoresheet.ranked_items(threshold=threshold))
        assert_dict_equal(d, dict(zip("xwvutsrqponm",
                                      reversed(range(12, 24)))))

    def test_with_too_large_threshold(self):
        threshold = 25
        for s in self.scoresheet.ranked_items(threshold=threshold):
            assert_less(len(s), threshold)

    def test_top(self):
        top = self.scoresheet.top()
        assert_dict_equal(top, dict(zip("opqrstuvwx", range(14, 24))))

        top = self.scoresheet.top(2)
        assert_dict_equal(top, dict(zip("wx", range(22, 24))))

        top = self.scoresheet.top(100)
        assert_equal(len(top), 24)
コード例 #3
0
ファイル: test_scoresheet.py プロジェクト: wct1998/linkpred
class TestBaseScoresheet:
    def setup(self):
        self.scoresheet = BaseScoresheet(
            zip("abcdefghijklmnopqrstuvwx", range(24)))

    def test_ranked_items(self):
        d = dict(self.scoresheet.ranked_items())
        assert d == dict(self.scoresheet)

        s = self.scoresheet.ranked_items()
        assert next(s) == ("x", 23)
        assert next(s) == ("w", 22)
        assert next(s) == ("v", 21)

    def test_sets_with_threshold(self):
        threshold = 12
        d = dict(self.scoresheet.ranked_items(threshold=threshold))
        assert d == dict(zip("xwvutsrqponm", reversed(range(12, 24))))

    def test_with_too_large_threshold(self):
        threshold = 25
        for s in self.scoresheet.ranked_items(threshold=threshold):
            assert len(s) < threshold

    def test_top(self):
        top = self.scoresheet.top()
        assert top == dict(zip("opqrstuvwx", range(14, 24)))

        top = self.scoresheet.top(2)
        assert top == dict(zip("wx", range(22, 24)))

        top = self.scoresheet.top(100)
        assert len(top) == 24

    def test_to_file_from_file(self):
        with temp_file() as fname:
            self.scoresheet.to_file(fname)

            newsheet = BaseScoresheet.from_file(fname)
            assert self.scoresheet == newsheet
コード例 #4
0
ファイル: test_scoresheet.py プロジェクト: TythonLee/linkpred
    def test_to_file_from_file(self):
        with temp_file() as fname:
            self.scoresheet.to_file(fname)

            newsheet = BaseScoresheet.from_file(fname)
            assert_dict_equal(self.scoresheet, newsheet)
コード例 #5
0
ファイル: test_scoresheet.py プロジェクト: TythonLee/linkpred
 def setup(self):
     self.scoresheet = BaseScoresheet(
         zip("abcdefghijklmnopqrstuvwx", range(24)))
コード例 #6
0
ファイル: test_scoresheet.py プロジェクト: royshan/linkpred
 def setup(self):
     self.scoresheet = BaseScoresheet(
         zip("abcdefghijklmnopqrstuvwx", range(24)))
コード例 #7
0
ファイル: test_scoresheet.py プロジェクト: wct1998/linkpred
    def test_to_file_from_file(self):
        with temp_file() as fname:
            self.scoresheet.to_file(fname)

            newsheet = BaseScoresheet.from_file(fname)
            assert self.scoresheet == newsheet
コード例 #8
0
    def test_to_file_from_file(self):
        with temp_file() as fname:
            self.scoresheet.to_file(fname)

            newsheet = BaseScoresheet.from_file(fname)
            assert_dict_equal(self.scoresheet, newsheet)