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

Add tests for inverses and derivatives #105

Closed
wants to merge 4 commits into from

Conversation

venpopov
Copy link
Contributor

@venpopov venpopov commented Apr 5, 2024

Making this a draft PR so you can see what I meant in #103

new functions

  • add methods eval_transform(dist, at), eval_inverse(dist, at) and eval_deriv(dist, at) which given a distribution object evaluate the corresponding transformation, inverse transformation or jacobian at the values in the at vector
  • these currently return the same as vec_data(dist)[[1]]['transform'] etc for a signle distribution, but could also be applied to a distribution vector. Their output format matches that of density(dist, at), etc.
  • all internal calls to dist"trainsform" replaced with eval_transform(dist, at), etc.
  • nicer to use from a user's perspective, but also potentially more future proof - any future changes to how transforms, inverses or derivatives are stored or accessed will not require changes to the core package functions such as density, etc. Rather, they will make changes in the eval_*() methods
  • this also makes it easier to define tests that don't need to be changed if the methods for storing, accessing or calculating these functions change

new tests

  • in test-utils - test that the format output of eval_*() functions is correct and matches that of the other user facing functions such as density()
  • expect_correct_inverse() and expect_correct_derivative() in test-transformed, test for a wide array of simple and nested transformations

I think more tests should be added, but I wanted to share this as it is now so that you can see the idea behind what I mentioned in #103

@mitchelloharawild mitchelloharawild added this to the v1.0.0 milestone Apr 19, 2024
@venpopov venpopov closed this by deleting the head repository Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants