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

#1366 - Approximate equality test for Rationals #1367

Merged
merged 3 commits into from
May 13, 2019
Merged

Conversation

schillic
Copy link
Member

Closes #1366.

The last commit is unrelated, but I found it weird that we have different (and actually inconsistent) behavior for Rationals. I would actually argue that we should also remove the default for _leq for the same reason, but I did not have a closer look at it.

@schillic schillic requested a review from mforets May 13, 2019 14:12
@mforets
Copy link
Member

mforets commented May 13, 2019

Rationals can and should use exact comparisons; what i suggested here to share the interface, is to just let isapproxzero(x::Real, ...) handle it (but don't remove it!).

@schillic
Copy link
Member Author

schillic commented May 13, 2019

Yes, but the other implementation uses exact comparison, so I argue that we can use the float method in all cases (which simplifies things). Furthermode, if one wants to change the tolerance for new number types, one can simply override ABSZTOL and it works automatically. This is not the case with the removed method.

@mforets
Copy link
Member

mforets commented May 13, 2019

Oh, true, with ABSZTOL(N::Type{Rational{INNER}}) where {INNER} = zero(N) even abs(x) <= ztol has the same behavior as checking that x is zero.

@schillic schillic merged commit b011aa1 into master May 13, 2019
@schillic schillic deleted the schillic/isapprox branch May 13, 2019 16:50
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.

Approximate equality test for Rationals
2 participants