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

Add float_compare_mode for comparing floats with epsilon #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JonathanMurray
Copy link

@JonathanMurray JonathanMurray commented Jun 27, 2023

Solves #29

@JonathanMurray
Copy link
Author

Hi! I have some test-cases that need to account for small differences in floating point values. The need is very similar to what's suggested in #29, so I took a stab at implementing it here.

I started out with the less verbose syntax .float_eq_epsilon(0.001), but changed it to an enum midway to try to maintain more consistency with the existing options, and make it easier to document the two cases (what happens if you specify an epsilon, and what happens if you don't). If we prefer the more concise version, that's easy to change though.

Does the approach look sensible, or am I missing some nuance?

Oh, I also had to pull in an extra dependency. Seemed reasonable to me, not trying to implement the float comparisons by hand, although it pained me to grow the list of dependencies from 2 to 3 😄

@JonathanMurray
Copy link
Author

@davidpdrsn Does this implementation look reasonable to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant