Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
Add a JSON writer callback, allowing for output of structured information.
Description:
The current writer callback methods are only defined for atomic elements and vectors. The Stan services layer uses these callbacks to assemble inference outputs into CSV files. Any structured information must either flattened or output as comments which require custom, ad-hoc post-procesing.
To implement this we need to introduce a new writer class: stan::io::structured_writer which adds:
begin - called by constructor
'keyed_begin` - called for nested objects
end - called by destructor and as needed
keyed_string
keyed_vector
...
everywhere we need to keep track of how many of each entry because JSON is picky about trailing commas
figure out where the best place to put this logic is.
Summary:
Add a JSON writer callback, allowing for output of structured information.
Description:
The current writer callback methods are only defined for atomic elements and vectors. The Stan services layer uses these callbacks to assemble inference outputs into CSV files. Any structured information must either flattened or output as comments which require custom, ad-hoc post-procesing.
The immediate use case for JSON output is to output diagnostics from the single-path Pathfinder algorithm - see https://github.com/stan-dev/stan/pull/3123 - https://github.com/stan-dev/stan/pull/3123#issuecomment-1490936361
More use cases are outlined in the https://github.com/stan-dev/design-docs/blob/master/designs/0032-stan-output-formats.md
To implement this we need to introduce a new writer class:
stan::io::structured_writer
which adds:begin
- called by constructorend
- called by destructor and as neededkeyed_string
keyed_vector
everywhere we need to keep track of how many of each entry because JSON is picky about trailing commas figure out where the best place to put this logic is.
so that we can create nested records.
Current Version:
v2.31.0