From fa1deca144210e519acc71e8fa9c8e004fc6f760 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 31 Dec 2019 04:12:50 +0300 Subject: [PATCH] Fix wrong tests --- Tests/images/imagedraw_floodfill_L.png | Bin 144 -> 145 bytes Tests/images/imagedraw_polygon_kite_L.png | Bin 499 -> 498 bytes Tests/test_image_entropy.py | 6 +++--- Tests/test_image_getdata.py | 6 +++--- Tests/test_image_getextrema.py | 8 ++++---- Tests/test_image_histogram.py | 6 +++--- Tests/test_imagecolor.py | 6 +++--- src/PIL/ImageColor.py | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Tests/images/imagedraw_floodfill_L.png b/Tests/images/imagedraw_floodfill_L.png index 4139e66d84e5159d161ed71025a97e987c6b32c1..daaf9422d3050370484eb934e065531b3a7f9b95 100644 GIT binary patch delta 116 zcmbQhIFWIJN^XRwi(^Q|oVPa)@-`?4xH=kKS@?Il>ePUP=8=5IX3SKU{&sh}DFZ{@ z;^QaR=vyEDeIkBc)?>fs#k(@wJJ7)i?}_b;qxMW>WcU!st@oMPn>pmcCk7z!boFyt I=akR{03y*eO8@`> delta 115 zcmbQpIDv73N=~?^i(^Q|oVPa)avo6NaR}7D>->Gbm-$N;!Js3}d&*5z{^w~jFvL9O zR5z|)!}>md&!x@1g1lMZF3BrlfOe&B|E-0K_!$nk$*bx!dtI8r5WxThp00i_>zopr E0L}C#oB#j- diff --git a/Tests/images/imagedraw_polygon_kite_L.png b/Tests/images/imagedraw_polygon_kite_L.png index 241d86bf40d72676f7e2652e42a9d0bea15f9f9f..0d9a1c8f81677324ae1e29610df9727fa69cf5e3 100644 GIT binary patch delta 472 zcmV;}0Vn?R1M&lqB!9U{L_t(|obB1malmZTZDB~AuRDLzSsflm@(z>MOM6d5=qK?Y1Hcal1TJ4u28BV{R(Fjz{G z3>YZ3M8&|C6c})&7!n}^LsDeGg))<98O$UC2K1CcB4;p2L=5OCy<`W2ULs^bOKBvV z80?fZ|H-5I`G5I*35zt@_H?!H$)mrt2ea#q@4j7+;qnH|rmt|no{SRom^~}wWsRRo z5M#FNR<8RlOM()!V+T3xg%=WJm<_x7@qDtDpuy-*T9Y&5tpou^e)^rA<2@3p7xz(JpBEgGMO-xsisstCNE&<-Kf~fL=dHl)ANj-n+)_Z(y+v~aj O0000rrB!9X|L_t(|obB05Zo@DPMbX=!+bFV;Es;Bwk45pa&mGK%=-f+-apGK--;T)H#dCMOYjTudfK;?CASR9l79v)DK&|QK~2&y zU_~iNoD2$*3j-FEti;bCE159Brlcex1}TZb0Fx4zL>a^-3x5V!l%OQRASk(EfI*2! zattC82Lt95w%U~uEFrcRl5;=oGB4R*C=_NZD^b#QhT1q3? z#9*hS`A;6r&wtP7OIW1Iwx_FoPagfHJ(yi@eE02o43{@xHhqQr^<I+9DWKuB74!7B>Pe=%3gi{B5ev*?A z!{{bKi6-1Q}%;Qf^PU`ssIRbl%;1ERC P00000NkvXXu0mjfVHnI) diff --git a/Tests/test_image_entropy.py b/Tests/test_image_entropy.py index bc792bca6..941f7665d 100644 --- a/Tests/test_image_entropy.py +++ b/Tests/test_image_entropy.py @@ -7,9 +7,9 @@ class TestImageEntropy(PillowTestCase): return hopper(mode).entropy() self.assertAlmostEqual(entropy("1"), 0.9138803254693582) - self.assertAlmostEqual(entropy("L"), 7.06650513081286) - self.assertAlmostEqual(entropy("I"), 7.06650513081286) - self.assertAlmostEqual(entropy("F"), 7.06650513081286) + self.assertAlmostEqual(entropy("L"), 7.063008716585465) + self.assertAlmostEqual(entropy("I"), 7.063008716585465) + self.assertAlmostEqual(entropy("F"), 7.063008716585465) self.assertAlmostEqual(entropy("P"), 5.0530452472519745) self.assertAlmostEqual(entropy("RGB"), 8.821286587714319) self.assertAlmostEqual(entropy("RGBA"), 7.42724306524488) diff --git a/Tests/test_image_getdata.py b/Tests/test_image_getdata.py index 18d381390..122ca3494 100644 --- a/Tests/test_image_getdata.py +++ b/Tests/test_image_getdata.py @@ -20,9 +20,9 @@ class TestImageGetData(PillowTestCase): return data[0], len(data), len(list(data)) self.assertEqual(getdata("1"), (0, 960, 960)) - self.assertEqual(getdata("L"), (16, 960, 960)) - self.assertEqual(getdata("I"), (16, 960, 960)) - self.assertEqual(getdata("F"), (16.0, 960, 960)) + self.assertEqual(getdata("L"), (17, 960, 960)) + self.assertEqual(getdata("I"), (17, 960, 960)) + self.assertEqual(getdata("F"), (17.0, 960, 960)) self.assertEqual(getdata("RGB"), ((11, 13, 52), 960, 960)) self.assertEqual(getdata("RGBA"), ((11, 13, 52, 255), 960, 960)) self.assertEqual(getdata("CMYK"), ((244, 242, 203, 0), 960, 960)) diff --git a/Tests/test_image_getextrema.py b/Tests/test_image_getextrema.py index 228eb82c8..78695c06b 100644 --- a/Tests/test_image_getextrema.py +++ b/Tests/test_image_getextrema.py @@ -9,14 +9,14 @@ class TestImageGetExtrema(PillowTestCase): return hopper(mode).getextrema() self.assertEqual(extrema("1"), (0, 255)) - self.assertEqual(extrema("L"), (0, 255)) - self.assertEqual(extrema("I"), (0, 255)) - self.assertEqual(extrema("F"), (0, 255)) + self.assertEqual(extrema("L"), (1, 255)) + self.assertEqual(extrema("I"), (1, 255)) + self.assertEqual(extrema("F"), (1, 255)) self.assertEqual(extrema("P"), (0, 225)) # fixed palette self.assertEqual(extrema("RGB"), ((0, 255), (0, 255), (0, 255))) self.assertEqual(extrema("RGBA"), ((0, 255), (0, 255), (0, 255), (255, 255))) self.assertEqual(extrema("CMYK"), ((0, 255), (0, 255), (0, 255), (0, 0))) - self.assertEqual(extrema("I;16"), (0, 255)) + self.assertEqual(extrema("I;16"), (1, 255)) def test_true_16(self): with Image.open("Tests/images/16_bit_noise.tif") as im: diff --git a/Tests/test_image_histogram.py b/Tests/test_image_histogram.py index 8d34658b8..fa1ea1d4b 100644 --- a/Tests/test_image_histogram.py +++ b/Tests/test_image_histogram.py @@ -8,9 +8,9 @@ class TestImageHistogram(PillowTestCase): return len(h), min(h), max(h) self.assertEqual(histogram("1"), (256, 0, 10994)) - self.assertEqual(histogram("L"), (256, 0, 638)) - self.assertEqual(histogram("I"), (256, 0, 638)) - self.assertEqual(histogram("F"), (256, 0, 638)) + self.assertEqual(histogram("L"), (256, 0, 662)) + self.assertEqual(histogram("I"), (256, 0, 662)) + self.assertEqual(histogram("F"), (256, 0, 662)) self.assertEqual(histogram("P"), (256, 0, 1871)) self.assertEqual(histogram("RGB"), (768, 4, 675)) self.assertEqual(histogram("RGBA"), (1024, 0, 16384)) diff --git a/Tests/test_imagecolor.py b/Tests/test_imagecolor.py index e4a7b7dfe..4f42ecc93 100644 --- a/Tests/test_imagecolor.py +++ b/Tests/test_imagecolor.py @@ -165,14 +165,14 @@ class TestImageColor(PillowTestCase): self.assertEqual(0, ImageColor.getcolor("black", "L")) self.assertEqual(255, ImageColor.getcolor("white", "L")) - self.assertEqual(162, ImageColor.getcolor("rgba(0, 255, 115, 33)", "L")) + self.assertEqual(163, ImageColor.getcolor("rgba(0, 255, 115, 33)", "L")) Image.new("L", (1, 1), "white") self.assertEqual(0, ImageColor.getcolor("black", "1")) self.assertEqual(255, ImageColor.getcolor("white", "1")) # The following test is wrong, but is current behavior # The correct result should be 255 due to the mode 1 - self.assertEqual(162, ImageColor.getcolor("rgba(0, 255, 115, 33)", "1")) + self.assertEqual(163, ImageColor.getcolor("rgba(0, 255, 115, 33)", "1")) # Correct behavior # self.assertEqual( # 255, ImageColor.getcolor("rgba(0, 255, 115, 33)", "1")) @@ -180,5 +180,5 @@ class TestImageColor(PillowTestCase): self.assertEqual((0, 255), ImageColor.getcolor("black", "LA")) self.assertEqual((255, 255), ImageColor.getcolor("white", "LA")) - self.assertEqual((162, 33), ImageColor.getcolor("rgba(0, 255, 115, 33)", "LA")) + self.assertEqual((163, 33), ImageColor.getcolor("rgba(0, 255, 115, 33)", "LA")) Image.new("LA", (1, 1), "white") diff --git a/src/PIL/ImageColor.py b/src/PIL/ImageColor.py index 692d7d2c3..5a8e53bb8 100644 --- a/src/PIL/ImageColor.py +++ b/src/PIL/ImageColor.py @@ -134,7 +134,7 @@ def getcolor(color, mode): if Image.getmodebase(mode) == "L": r, g, b = color - color = (r * 299 + g * 587 + b * 114) // 1000 + color = (r * 299 + g * 587 + b * 114 + 500) // 1000 if mode[-1] == "A": return (color, alpha) else: