Skip to content
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

Reduce boilerplate for implementing alternate versions of Distributions #421

Open
SamuelBrand1 opened this issue Aug 15, 2024 · 1 comment
Labels
enhancement New feature or request EpiAware

Comments

@SamuelBrand1
Copy link
Collaborator

          Nice looks good. As we discussed its a lot of copy and paste so ideally we should have an issue to track changes we can make to reduce this (either here or upstream).

Originally posted by @seabbs in #418 (review)

@SamuelBrand1
Copy link
Collaborator Author

To flesh this out a bit. Implementing SafePoisson and SafeNegativeBinomial was done in a really boilerplate way, involving a lot of copy and paste from Distributions.jl and RandomPoisson.jl.

Possible preferable alternatives:

  • A macro based approach which generates the various functions to make a Safe version of a dist e.g.
@make_safe_distr Poisson
# SafePoisson is available
  • A traits based approach where we can make a trait-based dispatch without having to redeclare a lot of auxillary functions e.g. something like
@traitdef IsUnsafe{Poisson}
@traitfn rand(d::Poisson) where {Poisson; IsUnsafe{Poisson}} = safe_rand_method(d)

@SamuelBrand1 SamuelBrand1 added enhancement New feature or request EpiAware labels Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request EpiAware
Projects
None yet
Development

No branches or pull requests

1 participant