File: test_image_entropy.py

package info (click to toggle)
pillow 8.1.2%2Bdfsg-0.3%2Bdeb11u2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 65,628 kB
  • sloc: python: 35,630; ansic: 31,009; makefile: 388; javascript: 114; sh: 77
file content (16 lines) | stat: -rw-r--r-- 701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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.0530452472519745), 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