-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add inverse
and simplify type structure
#48
Conversation
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
==========================================
+ Coverage 83.33% 83.60% +0.27%
==========================================
Files 7 8 +1
Lines 66 61 -5
==========================================
- Hits 55 51 -4
+ Misses 11 10 -1
Continue to review full report at Codecov.
|
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.
Looks good! Should be easier to create new links now!
Would that make sense to create a macro for creating named links? like
@link CosLink cos
# returns
# const CosLink = Link{typeof(cos)}
# CosLink() = Link(cos)
I would rather want to deprecate the aliases to be honest. I think one should just use |
I have to say I find them quite needed. |
You could save 2 characters and write
Or you just use I still wonder if we should really define them in |
For once it's not even about the number of characters but more about readability 😆 I can see your point with the constructor though, but also I don't really see the negative effect of it either... Except for code everytime we want to create a new link... |
It's more definitions, more work for the compiler 🤷 But I guess mainly it's my desire to provide a cleaner API where links for functions should always be constructed with |
ToDo: Switch to InverseFunctions.jl. ;-) |
There's already an issue 😉 We can't switch before LogExpFunctions and StatsFuns support it though (if we don't want to introduce type piracy). |
Ah, right. I can get on that as soon as we have a ChangesOfVariables v1.1 with integrated test function out. |
This PR implements the suggestion in #43 (comment).
More concretely, if one defines
GPLikelihoods.inverse(::typeof(g)) = f
(probably one wants to define the reverse definition as well 😉) then one getsinv(::Link{typeof(g)}) isa Link{typeof(f)}
for free. This allows to defineLogLink
,ExpLink
just as aliases ofLink
.(As a hidden feature, in addition to existing links the PR also adds the suggestion in the linked comment for
log1pexp
andlogexpm1
, i.e.,Link(log1pexp)
andLink(logexpm1)
are invertible now as well.)In the future, maybe definitions for
inv(exp)
etc. might be available in base (JuliaLang/julia#42421) or as type piracy in some package which would make this approach even more composable and put less maintenance burden on us.