-
Notifications
You must be signed in to change notification settings - Fork 107
Added isapprox support for MultiValue #1158
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
Conversation
Antoinemarteau
left a comment
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.
Hello Miguel, thanks for your PR :)
I gave some comments, I think this can be merged after taking them into account and updating README.md.
Added to NEWS.md |
|
Hi @Antoinemarteau , thanks for your review. I've applied your suggestions. However, you'll see that I've faced limitations when applying some of the suggestions. The PR is ready to review again. |
|
I am just not sure why we are not just adding the kwargs to the pre-existing signature, instead of having two different ones? Like why not just change this: (≈)(a::MultiValue{S},b::MultiValue{S}) where {S} = isapprox(get_array(a), get_array(b))
(≈)(a::MultiValue{S,T1,N,0} where T1,b::MultiValue{S,T2,N,0} where T2) where {S,N} = trueto this: (≈)(a::MultiValue{S},b::MultiValue{S}; kwargs...) where {S} = isapprox(get_array(a), get_array(b); kwargs...)
(≈)(a::MultiValue{S,T1,N,0} where T1,b::MultiValue{S,T2,N,0} where T2; kwargs...) where {S,N} = trueor am I missing something? In my mind there is no need to have one signature with kwargs and one without. |
|
I agree @JordiManyer, I suggested replacing the line cause I liked removing So I would keep (≈)(a::MultiValue,b::MultiValue; kwargs...) = isapprox(get_array(a), get_array(b); kwargs...)
(≈)(a::MultiValue{S,T1,N,0} where T1,b::MultiValue{S,T2,N,0} where T2; kwargs...) where {S,N} = true |
|
Sure, I think we can even remove the zero-dimensional dispatch and just keep the first signature, right? I don't think it gets used much and even if it does I presume the fallback is just as fast? |
I'm afraid the binary operator
|
|
Then lets keep isapprox(a::MultiValue,b::MultiValue;kwargs...) = isapprox(get_array(a),get_array(b);kwargs...)and remove the rest. |
Got it. Done |
Its a minor detail, but this doesn't mean we need to overload I also agree that we can remove the signature for empty tensors, the new default works the same. |
Thanks for the explanation. Done |
Removed line 8 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1158 +/- ##
==========================================
- Coverage 89.27% 89.27% -0.01%
==========================================
Files 211 211
Lines 26693 26692 -1
==========================================
- Hits 23830 23829 -1
Misses 2863 2863
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you very much for your attention! |


This PR is a proposal to extend the interface of
MultiValue. Its implementation follows the pattern of #1157.Current behaviour
Right now, the function
isapprox(::MultiValue, ::MultiValue)is available with default arguments, but is not possible to pass optional arguments like tolerance.Proposed behaviour
After this PR, it will be able to call the function
isapproxwith optional arguments, e.g.isapprox(A,B,rtol=eps(1.0).