-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
implement equality for ComposedFunction structurally #54877
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
@test !==(F(eq=true) ∘ F(eq=false) , f2) | ||
@test !==(F(eq=false) ∘ F(eq=true) , f2) | ||
@test !==(F(eq=false) ∘ F(eq=false) , f2) | ||
end |
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.
end | |
@test ((missing ∘ sin) == (missing ∘ sin)) === missing | |
@test ((missing ∘ sin) == (missing ∘ cos)) === false | |
end |
Not sure, but presumably we'd like to intepret ComposedFunction
like a collection of functions, thus suppport missing
as usual.
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.
It is a good point, but orthogonal to this PR.
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.
To clarify, right now missing
is not handled specially by composion.
julia> missing∘missing
missing ∘ missing
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.
orthogonal to this PR.
I don't think so. Right now we have the excuse that ==
for ComposedFunction
isn't implemented at all, but if we're finally implementing it presumably the handling of missing
should be thought through.
right now
missing
is not handled specially by composion.
Composition doesn't need to handle missing
specially, just ==
. If ComposedFunction
is interpreted as a sort of collection of functions.
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.
You are right, sorry I misread some parenthesis in your test. I read (missing ∘ sin) === missing
.
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.
My takeaway from #54881 is ot not implement special logic for missing in composed function equality in this PR.
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.
I think it's possible to support missing
without any special missing
-specific logic.
I don't think it should be blocking here, and checking julia> (sin ∘ sin) ∘ sin != sin ∘ (sin ∘ sin)
true I.e, the binary nature of
I do not think |
Interesting. Basically, One solution would be to recursively convert the |
Yes, you stated the issue much more clearly than I did. Possibilities would be to convert it to Although I think this PR would be fine even if it didn't recognize re-associated |
end | ||
|
||
function ==(f1::ComposedFunction, f2::ComposedFunction)::Bool | ||
==(f1.inner, f2.inner) && ==(f1.outer, f2.outer) |
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.
==(f1.inner, f2.inner) && ==(f1.outer, f2.outer) | |
==(f1.inner, f2.inner) & ==(f1.outer, f2.outer) |
Support missing
and other non-Bool results of ==
by not short-circuiting.
@test !==(F(eq=true) ∘ F(eq=false) , f2) | ||
@test !==(F(eq=false) ∘ F(eq=true) , f2) | ||
@test !==(F(eq=false) ∘ F(eq=false) , f2) | ||
end |
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.
I think it's possible to support missing
without any special missing
-specific logic.
fix #53853