-
Notifications
You must be signed in to change notification settings - Fork 422
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
Switch to keyword constructors #768
Comments
(I suggested something like this in #584). |
Looks nice, what do you mean by trickery for the dispatch? |
I've actually now put together a package for the trickery part: |
Not sure I'm convinced by using macros for all Distribution constructors.
Unlike other packages, I appreciate this one can be read and used with just
knowledge of plain Julia.
This would mean people have to understand an other package to get how this
one is built
…On Wed, Sep 19, 2018, 20:54 Simon Byrne ***@***.***> wrote:
I've actually now put together a package for the trickery part:
https://github.com/simonbyrne/KeywordDispatch.jl
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#768 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHRRsoL_EOQ3mJ7U83kRDzgazJ8Hocq1ks5ucpL5gaJpZM4WfKTX>
.
|
Could do the R trick and just accept all the keywords and error/warn and use one if both |
About this kind of error, they could get a bit messy if yielded by a
NoKwDispatchError or such
…On Wed, Sep 19, 2018, 21:19 Dave Kleinschmidt ***@***.***> wrote:
Could do the R trick and just accept all the keywords and error/warn and
use one if both std and var are specified
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#768 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHRRsj_hwhnxCIxGX-zsPLWNjcAO7XT0ks5ucpi0gaJpZM4WfKTX>
.
|
Distributions already uses a lot of macros: we could put them in Distributions itself (which was my original plan), but it seemed easier to make it a separate package. I'm happy to make the errors more useful. re: allowing all the keywords: I actually tied this a while ago, but I ended up with a lot of boilerplate |
you could use |
Valid points for the exponential kw checks for Distributions with lots of
parameters, not sure how often this is the case
…On Wed, Sep 19, 2018, 21:26 Simon Byrne ***@***.***> wrote:
Distributions already uses a lot of macros: we could put them in
Distributions itself (which was my original plan), but it seemed easier to
make it a separate package. I'm happy to make the errors more useful.
re: allowing all the keywords: I actually tied this a while ago, but I
ended up with a lot of boilerplate if blocks, and the complexity
increases exponentially as you add more arguments.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#768 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHRRsuPTKdvUioyZtGtl9_-joCsjfHw9ks5ucppJgaJpZM4WfKTX>
.
|
I've created a demonstration on the Distributions.jl/src/univariate/continuous/gamma.jl Lines 41 to 55 in 247ab6d
|
interesting just checked it. A good point is that we can use it only for some distributions and it's not a breaking change |
I would like to take the opportunity to deprecate some of the more confusing "default value" ones, e.g. |
I think JuliaLang/julia#9498 may be relevant, if not internally, then for users. Not sure if it is ablocking issue or just one to be aware of. HTH? |
Are there still any plans to add this to Distributions.jl? I've definitely felt like this could be very useful before. |
Now that we have fast keywords (well, we will once JuliaLang/julia#29083 is fixed), I propose that we switch the constructors to use keywords. This has several advantages:
Normal(μ=1.0, σ=2.0)
makes clear that it is a standard deviation, not a variance.fit(Normal, x, σ=2.0)
could fit the MLE withσ
constrained.The text was updated successfully, but these errors were encountered: