Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@b-ryan
This PR fixes issue #353 and adds a unittest. The fix is adding one line to
getOppositeColor
which needs to convert the rgb values to float before sending torgb_to_hls
. This stackoverflow article helped narrow down the solution.This issue only occurred on hostnames that happened to hash to a value in ranges that would be computed incorrectly by
rgb_to_hls
. In most instances the returned opposite values fromgetOppositeColor
would be a -1 in the r,g, or b position. The unittest added also caught, although is not asserting, ZeroDivisionError exceptions that occurred inrgb_to_hls
.Unfortunately, the unittest could not realistically be written to test 2^24 values that my be computed against a hostname (I tried....but did not have enough memory or patience to even build/run the parameterized tests. I did run a unittest that was not parameterized and got a successful result against the 2^24 but any failures discovered by that unittest would be hard to narrow down, given it was a one and done unittest...it did take a long time but required little to no memory). The test is written to test 768 values via parameterized package, which was added to the requirements-dev.txt. If you uncomment the conversion to float in
getOppositeColor
, you will get 192 assertions and 3 errors.