-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support unprotected mode for specials with FullRank
schemas as well
#274
Conversation
Would it make sense to introduce an |
I actually first tried doing |
Too bad. Then would it make sense to have |
yueah that's actually not a bad idea. it gets a bit tricky to write the macro that way though...maybe with a varargs it woudl be okay...let me play around a bit |
Looks good. Can you add tests? |
okay, another thing that's turned up in doing the MixedModels upgrade is that it would be very, very handy to have methods like |
(for the time being I think it's fine to vendor this in MixedModels as |
Co-authored-by: Milan Bouchet-Valat <[email protected]>
I'm okay with that --- MixedModels also has the whole |
@nalimilan I've added tests (and fixed a very obvious bug that the tests caught, so thank you for that suggestion 😁 ) |
test/protect.jl
Outdated
function ft(f) | ||
return function(args...) | ||
return FunctionTerm(f, args, :($f($(args...)))) | ||
end | ||
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.
Why not define this simply as:
function ft(f) | |
return function(args...) | |
return FunctionTerm(f, args, :($f($(args...)))) | |
end | |
end | |
ft(f, args...) = FunctionTerm(f, args, :($f($(args...)))) |
and call it as ft(op, a, b)
instead of ft(op)(a, b)
?
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.
yeah that works too! I think the version here was inspired by the "lift" model of "passmissing" and friends. But for tests I'm kind of indifferent.
@nalimilan I updated teh tests based on your suggestion, read for re-review. |
This is a follow-up to #183 which extends
@support_unprotect
to provide support for arbitrary schema types, and uses that to generate support for specials (+
,&
,*
, and~
) for bothSchema
andFullRank
.This is necessary to support cases like mixed models where we do things like (taking some liberties here with the actual method signature)
lhs
may be1
, or1 + x
, or evenlog(x)
, so we can't blindly "lift" functionterms on the lhs (e.g., do something likelhs = lhs isa FunctionTerm ? lhs.f(lhs.args...) : lhs
) because that would manglelog(x)
.