Metadata methods on the model class for output var type and size information

Hey @bgoodri, @jonah - you all were interested in metadata methods that return size and type information about Stan parameters, transformed parameters, and generated quantities. Here’s my proposed implementation with an example:

In that example, it’s printing things like "<< K >>" to indicate that we will do string interpolation on those sizes later on, so the output would actually be filled in with whatever K is set to in the data or transformed data block.

How’s that look? If that works, it should be merged soon and in the next release candidate if you all want to start playing with it.

The PR didn’t have a description or a link to an issue.
I looked through cpp.expected in the PR and as far as I can tell, the difference aside from implementation is two new methods:

std::string get_constrained_types() const;
std::string get_unconstrained_types() const;

Are you imaginging that R does some kind of string manipulation and then execs relative to something like an environment representing the data?

Can we add something to the name to indicate that this is both types and sizes?

Yep, those are the two new methods talked about in the roadmap draft. I also linked to a specific line with actual example string output. The C++ interpolates the json string with the actual size information (present only after the model has been instantiated). I’m not sure where R string manipulation or exec comes in - it’s all happening in C++. A normal JSON string is returned.

I can change the name to get_constrained_sizedtypes().

It’s not important. I didn’t mean to suggest changes to the roadmap if things have been decided.

Thanks—I wasn’t sure whether that was happening on the C++ side or the client side from the description or example.

I missed that. Where’s the link? I saw this comment in the PR.

Oh, I think maybe my link was broken. Here’s a good one: (and I’ll edit the OP).

1 Like

Thanks—that’s what I was expecting given the description.