Exemplo n.º 1
0
 def test_rank_values_14(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"a": 4.0, "b": 2.0, "d": 5.0, "f": 3.0, "e": 1.0}
     expected = {"a": 2, "b": 4, "d": 1, "f": 3, "e": 5}
     self.validate(
         ids, expected,
         CompetitionPhase.rank_values(ids, input, sort_ascending=False))
Exemplo n.º 2
0
 def test_rank_values_10(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"e": 1.0, "a": 1.001}
     expected = {"a": 2, "b": 3, "d": 3, "f": 3, "e": 1}
     self.validate(
         ids, expected,
         CompetitionPhase.rank_values(ids, input, sort_ascending=True))
Exemplo n.º 3
0
 def test_rank_values_2(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {}
     expected = {"a": 1, "b": 1, "d": 1, "f": 1, "e": 1}
     self.validate(
         ids, expected,
         CompetitionPhase.rank_values(ids, input, sort_ascending=False))
Exemplo n.º 4
0
    def test_format_values(self):
        x = 0.12834956
        self.assertEqual("0.1", CompetitionPhase.format_value(x, "1"))
        self.assertEqual("0.13", CompetitionPhase.format_value(x, "2"))
        self.assertEqual("0.128", CompetitionPhase.format_value(x, "3"))
        self.assertEqual("0.1283", CompetitionPhase.format_value(x, "4"))
        self.assertEqual("0.12835", CompetitionPhase.format_value(x, "5"))

        self.assertEqual("0.13", CompetitionPhase.format_value(x))

        self.assertEqual("0.1", CompetitionPhase.format_value(x, "0"))
        self.assertEqual("0.1283495600",
                         CompetitionPhase.format_value(x, "20"))

        self.assertEqual("0.1", CompetitionPhase.format_value(x, "-2"))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, "2.13"))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, "2fooo"))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, ""))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, None))
Exemplo n.º 5
0
 def test_rank_values_12(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"a": 4.0, "b": 2.0, "d": 5.0, "f": 3.0, "e": 1.0}
     expected = {"a": 4, "b": 2, "d": 5, "f": 3, "e": 1}
     self.validate(ids, expected, CompetitionPhase.rank_values(ids, input))
Exemplo n.º 6
0
 def test_rank_values_3(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"d": 1.0}
     expected = {"a": 2, "b": 2, "d": 1, "f": 2, "e": 2}
     self.validate(ids, expected, CompetitionPhase.rank_values(ids, input))
Exemplo n.º 7
0
    def test_format_values(self):
        x = 0.12834956
        self.assertEqual("0.1", CompetitionPhase.format_value(x, "1"))
        self.assertEqual("0.13", CompetitionPhase.format_value(x, "2"))
        self.assertEqual("0.128", CompetitionPhase.format_value(x, "3"))
        self.assertEqual("0.1283", CompetitionPhase.format_value(x, "4"))
        self.assertEqual("0.12835", CompetitionPhase.format_value(x, "5"))

        self.assertEqual("0.13", CompetitionPhase.format_value(x))

        self.assertEqual("0.1", CompetitionPhase.format_value(x, "0"))
        self.assertEqual("0.1283495600",
                         CompetitionPhase.format_value(x, "20"))

        self.assertEqual("0.1", CompetitionPhase.format_value(x, "-2"))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, "2.13"))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, "2fooo"))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, ""))
        self.assertEqual("0.1", CompetitionPhase.format_value(x, None))
Exemplo n.º 8
0
 def test_rank_values_14(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"a": 4.0, "b": 2.0, "d": 5.0, "f": 3.0, "e": 1.0}
     expected = {"a": 2, "b": 4, "d": 1, "f": 3, "e": 5}
     self.validate(ids, expected, CompetitionPhase.rank_values(
         ids, input, sort_ascending=False))
Exemplo n.º 9
0
 def test_rank_values_12(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"a": 4.0, "b": 2.0, "d": 5.0, "f": 3.0, "e": 1.0}
     expected = {"a": 4, "b": 2, "d": 5, "f": 3, "e": 1}
     self.validate(ids, expected, CompetitionPhase.rank_values(ids, input))
Exemplo n.º 10
0
 def test_rank_values_10(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"e": 1.0, "a": 1.001}
     expected = {"a": 2, "b": 3, "d": 3, "f": 3, "e": 1}
     self.validate(ids, expected,
                   CompetitionPhase.rank_values(ids, input, sort_ascending=True))
Exemplo n.º 11
0
 def test_rank_values_3(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {"d": 1.0}
     expected = {"a": 2, "b": 2, "d": 1, "f": 2, "e": 2}
     self.validate(ids, expected, CompetitionPhase.rank_values(ids, input))
Exemplo n.º 12
0
 def test_rank_values_2(self):
     ids = {"a", "b", "d", "f", "e"}
     input = {}
     expected = {"a": 1, "b": 1, "d": 1, "f": 1, "e": 1}
     self.validate(ids, expected, CompetitionPhase.rank_values(
         ids, input, sort_ascending=False))