cpython: 80e9cb6163b4 (original) (raw)

--- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -251,6 +251,13 @@ platform-dependent. (Contributed by Chr The module supports new file types: door, event port and whiteout. +colorsys +-------- + +The number of digits in the coefficients for the RGB --- YIQ conversions have +been expanded so that they match the FCC NTSC versions. The change in +results should be less than 1% and may better match results found elsewhere. + Optimizations =============

--- a/Lib/colorsys.py +++ b/Lib/colorsys.py @@ -33,17 +33,25 @@ TWO_THIRD = 2.0/3.0

YIQ: used by composite video signals (linear combinations of RGB)

Y: perceived grey level (0.0 == black, 1.0 == white)

I, Q: color components

+# +# There are a great many versions of the constants used in these formulae. +# The ones in this library uses constants from the FCC version of NTSC. def rgb_to_yiq(r, g, b): y = 0.30r + 0.59g + 0.11*b

+

+ if r < 0.0: r = 0.0 if g < 0.0:

--- a/Lib/test/test_colorsys.py +++ b/Lib/test/test_colorsys.py @@ -1,4 +1,4 @@ -import unittest, test.support +import unittest import colorsys def frange(start, stop, step): @@ -69,8 +69,32 @@ class ColorsysTest(unittest.TestCase): self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls)) -def test_main():

+

if name == "main":

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,9 @@ Core and Builtins Library ------- +- Issue #14323: Expanded the number of digits in the coefficients for the