mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 13:46:57 +03:00
9f9e26522e
This fixes a bug with rounding pixels to the nearest palette color. Specifically, there is a typo with computing the minimum distance from a palette color to a given cache box. This is causing palette colors to be incorrectly excluded from consideration.
17 lines
700 B
Python
17 lines
700 B
Python
from .helper import hopper
|
|
|
|
|
|
def test_entropy():
|
|
def entropy(mode):
|
|
return hopper(mode).entropy()
|
|
|
|
assert round(abs(entropy("1") - 0.9138803254693582), 7) == 0
|
|
assert round(abs(entropy("L") - 7.063008716585465), 7) == 0
|
|
assert round(abs(entropy("I") - 7.063008716585465), 7) == 0
|
|
assert round(abs(entropy("F") - 7.063008716585465), 7) == 0
|
|
assert round(abs(entropy("P") - 5.082506854662517), 7) == 0
|
|
assert round(abs(entropy("RGB") - 8.821286587714319), 7) == 0
|
|
assert round(abs(entropy("RGBA") - 7.42724306524488), 7) == 0
|
|
assert round(abs(entropy("CMYK") - 7.4272430652448795), 7) == 0
|
|
assert round(abs(entropy("YCbCr") - 7.698360534903628), 7) == 0
|