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), )
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), )
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), )