-
Notifications
You must be signed in to change notification settings - Fork 89
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
Increase test result precision #2024
Conversation
The primary reason for this comparison being so low, as the comment indicates, is that the |
It is still not consistent. Thus in this PR I'm not trying to really increase the actual the precision used for testing. I noticed some matrices in w3 draft examples and color.js got updated and have different values than dart-sass: For example https://github.com/color-js/color.js/blob/40e7a059c639bafde14504627e62791588c63100/src/spaces/oklab.js#L10-L24 @nex3 Probably worth cross checking all matrices and see if they are accurate. |
BTW, w3c/csswg-drafts#6642 (comment) might explain what's happening with the precision issue here: sass-spec/js-api-spec/value/color/color-4-conversions.test.ts Lines 164 to 168 in 83bd499
|
This recomputes all existing LMS-related matrices based on the improved XYZD65/LMS matrices in w3c/csswg-drafts#6642#issuecomment-1490068959. See sass/sass-spec#2024
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.
Increasing precision here sounds good, given that all the tests pass. However, it's probably worth merging the changes for below and making sure that the high-precision values are still correct, given that OK* space conversions are now subtly different than they were before.
I noticed some matrices in w3 draft examples and color.js got updated and have different values than dart-sass: For example https://github.com/color-js/color.js/blob/40e7a059c639bafde14504627e62791588c63100/src/spaces/oklab.js#L10-L24
Oh, thanks for the tip. I'm updating our matrices in sass/dart-sass#2374.
BTW, w3c/csswg-drafts#6642 (comment) might explain what's happening with the precision issue here:
sass-spec/js-api-spec/value/color/color-4-conversions.test.ts
Lines 164 to 168 in 83bd499
// Certain channel values cause equality issues on 1-3 of 16*16*3 // cases. 0.45 is a magic number that works around this until the // root cause is determined. const scale = 0.45; const channelValue = destinationSpace.ranges[index][1] * scale;
I doubt we can fix this until Color.js is also using all the latest matrices (if it ever does).
This recomputes all existing LMS-related matrices based on the improved XYZD65/LMS matrices in w3c/csswg-drafts#6642#issuecomment-1490068959. See sass/sass-spec#2024
If I read the comment from the linked color.js code correctly I think they are already using updated matrices, and dart-sass being outdated might be why the results were off between the two, but maybe there will be other differences. Hard to know as the way color conversion path works is quite different. |
Hmm... the matrices added in color-js/color.js#357 match the CSS spec, but they're different from those described in w3c/csswg-drafts#6642 (comment), which the comments on that issue seem to indicate are the best currently available. I've asked for clarification in w3c/csswg-drafts#6642 (comment). |
One good-ish news is that after I updated the matrices in ruby implementation (a port of dart implementation) now I can reproduce the issue where the color conversion tests pass at precision of 4 digits, but fails at precision of 5 digits. So the LMS matrices might have been the root cause of the precision difference. Next thing to try is re-baseline all color conversion tests, and validate them against dart-sass vs color.js and see if they pass at higher precision. |
This recomputes all existing LMS-related matrices based on losslessly applying the logic described in w3c/csswg-drafts#6642 (comment). See sass/sass-spec#2024
@nex3 I spent sometime re-baselining all the outputs with embedded-host-node implementation on color.js 0.5.2 - and now when running at |
It's generally expected that we differ slightly from Color.js, because we're generally using more precise color transform inputs (especially for oklch and oklab, where we computed many steps losslessly). |
Never mind, I forgot to update my dart-sass build. |
f8657f1
to
9fa262a
Compare
Tests are now passing at |
Currently the js-api-spec runs at very low precision at
epsilon = (10 ** -2)
, so things are passing now.sass-spec/js-api-spec/setup.ts
Lines 358 to 363 in 3bb39e6
However, when I change the
epsilon
to10 ** -11
(the value sass uses internally), I got 6 test failures because the "expected" result does not have enough precision.