Skip to content
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

Fix floating point equality comparison in layouts #4972

Merged
merged 3 commits into from
Aug 23, 2024

Conversation

penelopeysm
Copy link
Contributor

@penelopeysm penelopeysm commented Aug 21, 2024

Description

Fixes #4971 by using an approximate equality check.

Attribution

Things to consider

  • Does it work on log scales?
  • Does it work in layouts?
  • Does it work in recipes?
  • Does it work with multiple series in one call?
  • PR includes or updates tests?
  • PR includes or updates documentation?

@penelopeysm
Copy link
Contributor Author

penelopeysm commented Aug 21, 2024

Couple of questions for anyone reviewing:

  1. Although I haven't managed to find a series of floats for which the sum is more than eps() away from 1, I'm still worried it's a bit too conservative. Would something like eps() * length(heights), or eps() * sqrt(length(heights)) be a more sensible tolerance? I don't have a theoretical background in numerical computing :)
  2. Do you want tests for these lines of code? Happy to add them if you do.
  3. If the PR is accepted, do you want me to port this to the v2 branch as well?

@BeastyBlacksmith
Copy link
Member

Couple of questions for anyone reviewing:

  1. Although I haven't managed to find a series of floats for which the sum is more than eps() away from 1, I'm still worried it's a bit too conservative. Would something like eps() * length(heights), or eps() * sqrt(length(heights)) be a more sensible tolerance? I don't have a theoretical background in numerical computing :)

IIRC isapprox compares the first half of the bits to be equal, that should be sufficient in this case, I think.

  1. Do you want tests for these lines of code? Happy to add them if you do.

Yes, please

  1. If the PR is accepted, do you want me to port this to the v2 branch as well?

Yes

Thanks for working on this ❤️

@penelopeysm
Copy link
Contributor Author

@BeastyBlacksmith Okay, I think this should be ready!

CI failures seem to be unrelated, they're occurring due to a bump in Latexify from 0.16.4 to 0.16.5, specifically this PR korsbo/Latexify.jl#298.

I don't mind fixing that in another PR :)

@BeastyBlacksmith BeastyBlacksmith merged commit 5f82fa7 into JuliaPlots:master Aug 23, 2024
4 of 14 checks passed
@penelopeysm penelopeysm deleted the 4971-fix-equality branch August 23, 2024 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants