예제 #1
0
 def test_get_compare(self):
     test_distribution_one = probability_distribution.ProbabilityDistribution(
         {
             1: 2,
             2: 3,
             3: 16,
             4: 1
         })
     test_distribution_two = probability_distribution.ProbabilityDistribution(
         {
             1: 1,
             2: 3,
             3: 6,
             4: 2
         })
     image_path = pathlib.Path(
         os.path.dirname(os.path.abspath(__file__)),
         "test_image",
         "windows" if sys.platform.startswith("win") else "linux",
         "TestProbabilityDistribution_test_get_compare.tiff",
     )
     image = test_distribution_one.get_compare(test_distribution_two,
                                               "option a", "option b")
     expected_image = Image.open(image_path)
     self.assertEqual(
         pil_image_to_byte_array.image_to_byte_array(expected_image),
         pil_image_to_byte_array.image_to_byte_array(image),
     )
 def test_get_compare_histogram(self):
     test_distribution_one = ProbabilityDistribution(
         self._probability_outcome_factory, {
             1: 2,
             2: 3,
             3: 6,
             4: 1,
             5: 1
         })
     test_distribution_two = ProbabilityDistribution(
         self._probability_outcome_factory, {
             0: 2,
             1: 1,
             2: 3,
             3: 6,
             4: 2
         })
     image_path = get_image_path(
         "TestProbabilityDistribution_test_get_compare_histogram.tiff", )
     image = test_distribution_one.get_compare_histogram(
         test_distribution_two)
     expected_image = Image.open(image_path)
     self.assertEqual(
         pil_image_to_byte_array.image_to_byte_array(expected_image),
         pil_image_to_byte_array.image_to_byte_array(image),
     )
예제 #3
0
 def test_get_at_least_histogram(self):
     test_distribution = probability_distribution.ProbabilityDistribution({
         2:
         1,
         3:
         2,
         4:
         4,
         5:
         8,
         6:
         4,
         7:
         2,
         8:
         1
     })
     image_path = pathlib.Path(
         os.path.dirname(os.path.abspath(__file__)),
         "test_image",
         "windows" if sys.platform.startswith("win") else "linux",
         "TestProbabilityDistribution_test_get_at_least_histogram.tiff",
     )
     image = test_distribution.get_at_least_histogram()
     expected_image = Image.open(image_path)
     self.assertEqual(
         pil_image_to_byte_array.image_to_byte_array(expected_image),
         pil_image_to_byte_array.image_to_byte_array(image),
     )
    def test_get_at_most_histogram(self):
        interpreter = PythonDiceInterpreter()
        program = ["10 * 1d4"]

        image_path = get_image_path(
            "TestPythonDiceInterpreter_test_get_at_most_histogram.tiff",
        )
        image = interpreter.get_at_most_histogram(program)
        expected_image = Image.open(image_path)
        self.assertEqual(
            pil_image_to_byte_array.image_to_byte_array(expected_image),
            pil_image_to_byte_array.image_to_byte_array(image),
        )
 def test_get_at_most_histogram(self):
     test_distribution = ProbabilityDistribution(
         self._probability_outcome_factory, {
             1: 1,
             2: 3,
             3: 6,
             4: 1
         })
     image_path = get_image_path(
         "TestProbabilityDistribution_test_get_at_most_histogram.tiff", )
     image = test_distribution.get_at_most_histogram()
     expected_image = Image.open(image_path)
     self.assertEqual(
         pil_image_to_byte_array.image_to_byte_array(expected_image),
         pil_image_to_byte_array.image_to_byte_array(image),
     )
예제 #6
0
    def test_get_at_most_histogram(self):
        interpreter = python_dice_interpreter.PythonDiceInterpreter()
        program = ["10 * 1d4"]

        image_path = pathlib.Path(
            os.path.dirname(os.path.abspath(__file__)),
            "test_image",
            "windows" if sys.platform.startswith("win") else "linux",
            "TestPythonDiceInterpreter_test_get_at_most_histogram.tiff",
        )
        image = interpreter.get_at_most_histogram(program)
        expected_image = Image.open(image_path)
        self.assertEqual(
            pil_image_to_byte_array.image_to_byte_array(expected_image),
            pil_image_to_byte_array.image_to_byte_array(image),
        )
    def test_get_at_least_histogram(self):
        interpreter = PythonDiceInterpreter()
        program = [
            "VAR save_roll = d20 + 8",
            "VAR burning_arch_damage = 9d6 + 9",
            "VAR pass_save = ( save_roll >= 19 ) ",
            "VAR damage_half_on_save = burning_arch_damage // (pass_save + 1)",
            "damage_half_on_save",
        ]

        image_path = get_image_path(
            "TestPythonDiceInterpreter_test_get_at_least_histogram.tiff",
        )
        image = interpreter.get_at_least_histogram(program)
        expected_image = Image.open(image_path)
        self.assertEqual(
            pil_image_to_byte_array.image_to_byte_array(expected_image),
            pil_image_to_byte_array.image_to_byte_array(image),
        )
예제 #8
0
    def test_get_at_least_histogram(self):
        interpreter = python_dice_interpreter.PythonDiceInterpreter()
        program = [
            "VAR save_roll = d20 + 8",
            "VAR burning_arch_damage = 9d6 + 9",
            "VAR pass_save = ( save_roll >= 19 ) ",
            "VAR damage_half_on_save = burning_arch_damage // (pass_save + 1)",
            "damage_half_on_save",
        ]

        image_path = pathlib.Path(
            os.path.dirname(os.path.abspath(__file__)),
            "test_image",
            "windows" if sys.platform.startswith("win") else "linux",
            "TestPythonDiceInterpreter_test_get_at_least_histogram.tiff",
        )
        image = interpreter.get_at_least_histogram(program)
        expected_image = Image.open(image_path)
        self.assertEqual(
            pil_image_to_byte_array.image_to_byte_array(expected_image),
            pil_image_to_byte_array.image_to_byte_array(image),
        )