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 issue 15763 - Document behavior of relative difference #5316

Merged
merged 2 commits into from Apr 10, 2017

Conversation

schveiguy
Copy link
Member

Also fix issue where symmetry was assumed when lhs was a value and rhs was not. Instead of swapping the arguments (which clearly isn't equivalent), I copied the implementation of the range processing, but for rhs instead of lhs.

issue where symmetry was assumed when lhs was a value and rhs was not.
@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
15763 std.math.approxEqual is not symmetric

@JackStouffer
Copy link
Member

Should have a test case

// lhs is number, rhs is array
return approxEqual(rhs, lhs, maxRelDiff, maxAbsDiff);
// lhs is number, rhs is range
for (; !rhs.empty; rhs.popFront())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's because you're copying the implementation from the other branch, but it's odd to not use foreach here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to change or ignore, not really a pressing issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between foreach and this is that foreach creates a copy, this doesn't. I don't know what the implications are in terms of ranges that may fail or have weird behavior because of this. As I'm not focused on that aspect, I'd prefer to leave the implementation as is, and worry about this in a separate pull.

I will note that the original implementation does make a copy when recursing, so in this case it's not a big deal. However, it would look odd to use foreach here and not in the other location.

@schveiguy
Copy link
Member Author

Should have a test case

I will look into adding one. Should be easy enough.

@schveiguy
Copy link
Member Author

test added @JackStouffer

@schveiguy
Copy link
Member Author

ping, this is pretty trivial.

@dlang-bot dlang-bot merged commit 74a339e into dlang:master Apr 10, 2017
@schveiguy schveiguy deleted the fix15763 branch April 10, 2017 18:02
@schveiguy
Copy link
Member Author

Thx @JackStouffer

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