New submission from Zac Hatfield-Dodds <zac.hatfield.do...@gmail.com>:

As part of the Mentored Sprints at PyCon US, Marielle wrote some property-based 
tests [1] for the colorsys module [2], which found two bugs.


Taking a YIQ color, converting to RGB, and back to YIQ can result in the Y 
coordinate varying by more 0.1 (where [0, 1] is the range of possible values).
For example: (0.0 1.0 2.2204460492503136e-16) -> RGB -> (0.0 
1.1102230246251568e-16 1.0)

Taking an RGB color and converting though HSV-RBG-HSV can result in very 
different saturation values - up to having S1==0 and S2==1.
For example: (0.0 1.0 2.2204460492503136e-16) -> RGB -> (0.0 
1.1102230246251568e-16 1.0)


You can reproduce additional examples and get error bounds from [3].


[1] https://pyfound.blogspot.com/2020/05/property-based-testing-for-python.html
[2] https://docs.python.org/3/library/colorsys.html
[3] https://github.com/Zac-HD/stdlib-property-tests/pull/13

----------
components: Library (Lib)
messages: 369197
nosy: Zac Hatfield-Dodds
priority: normal
severity: normal
status: open
title: Catastrophic loss of precision in colorsys module
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40668>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to