-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Add color_curve
RGBGFX test
#1554
base: master
Are you sure you want to change the base?
Conversation
Verbose logging ( Correct log (most platforms): https://pastebin.com/EffXYRg9 /*
* Computes the "relative size" of a proto-palette on this palette
*/
double relSizeOf(ProtoPalette const &protoPal) const {
// NOTE: this function must not call `uniqueColors`, or one of its callers will break!
double relSize = 0.;
for (uint16_t color : protoPal) {
auto n = std::count_if(RANGE(*this), [this, &color](ProtoPalAttrs const &attrs) {
ProtoPalette const &pal = (*_protoPals)[attrs.protoPalIndex];
return std::find(RANGE(pal), color) != pal.end();
});
// NOTE: The paper and the associated code disagree on this: the code has
// this `1 +`, whereas the paper does not; its lack causes a division by 0
// if the symbol is not found anywhere, so I'm assuming the paper is wrong.
relSize += 1. / (1 + n);
}
return relSize;
} Note that I have previously rewritten this function to not depend on |
I added some more logging, and it seems like the difference stems from |
Odd, according to cppreference.com "If several elements are equivalent to the smallest element, the iterator to the first such element is returned. If several elements are equivalent to the largest element, the iterator to the last such element is returned." So this may be a bug with mingw32's implementation. (I also could have sword I reimplemented this without |
🗡️ Turns out that Cc @aaaaaa123456789 as the resident floats expert. Possibly we'd make an equivalent comparison using only int ops..? (Multiplying by the respective denominators instead of employing division) |
I turned a pair of divisions into a pair of multiplications, and this test is now consistent across all platforms. (Amusingly, it does not yield the same order as before! But There is nonetheless still some discrepancy across platforms: This could be fixed by eliminating This is a little more involved, and more obscure. Should we implement this? |
Thanks so much! ❤️ I'll clean up this PR and merge (and maybe try out the integer-only approach). |
…ciency This was breaking test results on 32-bit MinGW
Turns out this was a bug with the |
Follow-up to #1553. Adds a test for
-C/--color-curve
support, which is breaking somehow on 32-bit MinGW.(The palette order changes from 0 1 2 3 4 5 6 7 to 2 1 5 4 7 6 3 0.)