forked from Rust-related/RustPython
Update colorsys.py and test_colorsys.py to 3.12 (#5198)
This commit is contained in:
committed by
GitHub
parent
d8f2bd04ac
commit
92c8b371ae
2
Lib/colorsys.py
vendored
2
Lib/colorsys.py
vendored
@@ -83,7 +83,7 @@ def rgb_to_hls(r, g, b):
|
||||
if l <= 0.5:
|
||||
s = rangec / sumc
|
||||
else:
|
||||
s = rangec / (2.0-sumc)
|
||||
s = rangec / (2.0-maxc-minc) # Not always 2.0-sumc: gh-106498.
|
||||
rc = (maxc-r) / rangec
|
||||
gc = (maxc-g) / rangec
|
||||
bc = (maxc-b) / rangec
|
||||
|
||||
10
Lib/test/test_colorsys.py
vendored
10
Lib/test/test_colorsys.py
vendored
@@ -69,6 +69,16 @@ class ColorsysTest(unittest.TestCase):
|
||||
self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb))
|
||||
self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
|
||||
|
||||
def test_hls_nearwhite(self): # gh-106498
|
||||
values = (
|
||||
# rgb, hls: these do not work in reverse
|
||||
((0.9999999999999999, 1, 1), (0.5, 1.0, 1.0)),
|
||||
((1, 0.9999999999999999, 0.9999999999999999), (0.0, 1.0, 1.0)),
|
||||
)
|
||||
for rgb, hls in values:
|
||||
self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb))
|
||||
self.assertTripleEqual((1.0, 1.0, 1.0), colorsys.hls_to_rgb(*hls))
|
||||
|
||||
def test_yiq_roundtrip(self):
|
||||
for r in frange(0.0, 1.0, 0.2):
|
||||
for g in frange(0.0, 1.0, 0.2):
|
||||
|
||||
Reference in New Issue
Block a user