Skip to content

Commit

Permalink
add hash value to histogram test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Sep 18, 2024
1 parent da049bb commit 2738966
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions Tests/test_image_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,34 @@
from .helper import hopper

expected_data = {
"1": (256, 0, 10994),
"CMYK": (1024, 0, 16384),
"F": (256, 0, 662),
"HSV": (768, 0, 1696),
"I": (256, 0, 662),
"I;16": (256, 0, 8192),
"I;16B": (256, 0, 8192),
"I;16L": (256, 0, 8192),
"I;16N": (256, 0, 8192),
"L": (256, 0, 662),
"LA": (512, 0, 662),
"La": (512, 0, 662),
"LAB": (768, 0, 1946),
"P": (256, 0, 1551),
"PA": (512, 0, 1551),
"RGB": (768, 4, 675),
"RGBA": (1024, 0, 16384),
"RGBa": (1024, 0, 16384),
"RGBX": (1024, 0, 16384),
"YCbCr": (768, 0, 1908),
"1": (256, 0, 10994, -6588993366496339844),
"CMYK": (1024, 0, 16384, 6499941520588169132),
"F": (256, 0, 662, -6473002676204311189),
"HSV": (768, 0, 1696, -6543359421857819796),
"I": (256, 0, 662, -6473002676204311189),
"I;16": (256, 0, 8192, 5889973619001565923),
"I;16B": (256, 0, 8192, 5889973619001565923),
"I;16L": (256, 0, 8192, 5889973619001565923),
"I;16N": (256, 0, 8192, 5889973619001565923),
"L": (256, 0, 662, -2745750633816556827),
"LA": (512, 0, 662, -7010327511106502095),
"La": (512, 0, 662, -7010327511106502095),
"LAB": (768, 0, 1946, -5543905267928649909),
"P": (256, 0, 1551, -8229466336626460515),
"PA": (512, 0, 1551, 5750919599917307801),
"RGB": (768, 4, 675, -7521681876442962674),
"RGBA": (1024, 0, 16384, -4362402434932696434),
"RGBa": (1024, 0, 16384, -4362402434932696434),
"RGBX": (1024, 0, 16384, -4362402434932696434),
"YCbCr": (768, 0, 1908, -1513926274659056238),
}


@pytest.mark.parametrize("mode", Image.MODES)
def test_histogram(mode: str) -> None:
h = hopper(mode).histogram()
assert (len(h), min(h), max(h)) == expected_data[mode]
# If all values are checked in the same assert and they don't match,
# the error message gets truncated. So use multiple asserts to see
# the full message.
assert (len(h), min(h), max(h)) == expected_data[mode][:3]
assert hash(tuple(h)) == expected_data[mode][3]

0 comments on commit 2738966

Please sign in to comment.