mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Update colorsys.py and test_colorsys.py to 3.12 (#5198)
This commit is contained in:
1 parent
d8f2bd04ac
commit
92c8b371ae
2 files changed
+11
-1
No files matched your search
Vendored
+1
-1
@@ -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
|
||||
|
||||
Vendored
+10
@@ -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