-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests/unittests: test black corner case for color_rgb2hsv() #9940
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about the HSV(0,0,0), but the float comparison is flaky. Do the hue and saturation values matter when it is all black or all white?
This is not my area of expertise, but it seems kind of irrelevant to compare the hue of black.
Mostly FYI in the case someone is interested. I converted the HSV data structures partially into fixed point, since I suspected that floats could have caused instability. The result is in this commit: It is not ready to land, but maybe someone wants to pick it up or have a look at it. I am not planning to continue with it; if anyone feels like grabbing, please go ahead. |
c00573c
to
5dbb1a1
Compare
@gebart I adapted the PR according to @pekkanikander's proposal. Can you have another look? |
@kaspar030 could you maybe have a look at this :-/? |
@benpicco you want to maybe have a look at this 😁? |
True, but that doesn't test the case this PR was originally introduced for: #9939 |
Well technically they could be any random value… Maybe someone comes up with a better implementation where it's left uninitialized, that would still be valid. |
so what are you asking? |
I'd remove the test for |
Done |
Looks good, please squash! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For black, Value must be 0, Saturation can be 0 and Hue is not defined.
This test ensures that.
Tests a (currently undocumented) behavior of `color_rgb2hsv()`, that a black RGB value (all zero) causes the HSV value to be all zero.
097fce0
to
2c9ac91
Compare
Squashed |
I believe @gebart's comments were addressed. |
tbh, comparing a |
19693: sys/color: extend unittest and fix module r=kfessel a=kfessel ### Contribution description this extends the unittest for sys_color testing more colors ### Testing procedure ``` RIOT_tree/tests/unittests$ make tests-color test ``` will fail since our `rgb2hsv` implementation is wrong (or is using an other colorspace than hsv2rgb (without documenting)) the new `hsv2rgb` test will succeed ### Issues/PRs references #19614 was the reason i had a look at this #1315 added the rgb2hsv and hsv2rgb function #9940 added the test for black special case https://www.vagrearg.org/content/hsvrgb << some optimization for that function (avoiding float) Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
19378: sys: add common imath module mv isin() form test/driver_dac_dds r=kfessel a=benpicco 19693: sys/color: extend unittest and fix module r=kfessel a=kfessel ### Contribution description this extends the unittest for sys_color testing more colors ### Testing procedure ``` RIOT_tree/tests/unittests$ make tests-color test ``` will fail since our `rgb2hsv` implementation is wrong (or is using an other colorspace than hsv2rgb (without documenting)) the new `hsv2rgb` test will succeed ### Issues/PRs references #19614 was the reason i had a look at this #1315 added the rgb2hsv and hsv2rgb function #9940 added the test for black special case https://www.vagrearg.org/content/hsvrgb << some optimization for that function (avoiding float) Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de> Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
19378: sys: add common imath module mv isin() form test/driver_dac_dds r=maribu a=benpicco 19693: sys/color: extend unittest and fix module r=kfessel a=kfessel ### Contribution description this extends the unittest for sys_color testing more colors ### Testing procedure ``` RIOT_tree/tests/unittests$ make tests-color test ``` will fail since our `rgb2hsv` implementation is wrong (or is using an other colorspace than hsv2rgb (without documenting)) the new `hsv2rgb` test will succeed ### Issues/PRs references #19614 was the reason i had a look at this #1315 added the rgb2hsv and hsv2rgb function #9940 added the test for black special case https://www.vagrearg.org/content/hsvrgb << some optimization for that function (avoiding float) Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de> Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
19693: sys/color: extend unittest and fix module r=kfessel a=kfessel ### Contribution description this extends the unittest for sys_color testing more colors ### Testing procedure ``` RIOT_tree/tests/unittests$ make tests-color test ``` will fail since our `rgb2hsv` implementation is wrong (or is using an other colorspace than hsv2rgb (without documenting)) the new `hsv2rgb` test will succeed ### Issues/PRs references #19614 was the reason i had a look at this #1315 added the rgb2hsv and hsv2rgb function #9940 added the test for black special case https://www.vagrearg.org/content/hsvrgb << some optimization for that function (avoiding float) Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
19693: sys/color: extend unittest and fix module r=maribu a=kfessel ### Contribution description this extends the unittest for sys_color testing more colors ### Testing procedure ``` RIOT_tree/tests/unittests$ make tests-color test ``` will fail since our `rgb2hsv` implementation is wrong (or is using an other colorspace than hsv2rgb (without documenting)) the new `hsv2rgb` test will succeed ### Issues/PRs references #19614 was the reason i had a look at this #1315 added the rgb2hsv and hsv2rgb function #9940 added the test for black special case https://www.vagrearg.org/content/hsvrgb << some optimization for that function (avoiding float) Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
Contribution description
Tests a (currently undocumented) behavior of
color_rgb2hsv()
, that ablack RGB value (all zero) causes the HSV value to be all zero.
Testing procedure
Run the unittests for
color
(make -C tests/unittests tests-color test
). With current master they will fail, but #9939 fixes them.Issues/PRs references
Requires #9939 for the test to succeed.