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

Expose new base class method 'unconstrain_array' #3179

Merged
merged 10 commits into from
May 4, 2023

Conversation

WardBrian
Copy link
Member

@WardBrian WardBrian commented Apr 11, 2023

Submission Checklist

  • Run unit tests: ./runTests.py src/test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

Summary

This exposes the method added in stan-dev/stanc3#1305 as a direct inverse function for write_array. unconstrain_array takes in a vector of parameters on the constrained scale in the same order that write_array produced them and produces a vector of parameters on the unconstrained scale in the same order that write_array and log_prob expect.

This allows us to write what we want to write in almost all cases where we are using array_var_context followed by transform_inits at the moment (standalone generated quantities, the log_prob service function, etc). This is very useful for new features like tuples, ragged arrays, etc, since it weakens the reliance on the model.get_dims() function which fundamentally assumes that parameters are rectangular.

Intended Effect

Exposes unconstrain_array to the model base class. This function is already generated by the compiler.

How to Verify

Tests are added for the function directly and the standalone generated quantities service has been updated to use this new code.

Side Effects

None

Documentation

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
Simons Foundation

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@WardBrian WardBrian changed the title [WIP] Expose new base class method 'unconstrain_array' Expose new base class method 'unconstrain_array' May 3, 2023
@WardBrian WardBrian marked this pull request as ready for review May 3, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants