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

Feature/3176 json #3191

Merged
merged 40 commits into from
May 24, 2023
Merged

Feature/3176 json #3191

merged 40 commits into from
May 24, 2023

Conversation

mitzimorris
Copy link
Member

Submission Checklist

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

Summary

Add callback writer to output JSON data.

Intended Effect

Allow structured outputs in JSON format, per design-docs spec https://github.com/stan-dev/design-docs/blob/master/designs/0032-stan-output-formats.md

How to Verify

Unit tests

Side Effects

None

Documentation

N/A

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): Coumbia University

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

@mitzimorris mitzimorris requested a review from SteveBronder May 16, 2023 18:50
@mitzimorris mitzimorris requested a review from WardBrian May 16, 2023 18:56
src/stan/callbacks/unique_stream_writer.hpp Outdated Show resolved Hide resolved
src/stan/callbacks/unique_stream_writer.hpp Outdated Show resolved Hide resolved
src/stan/callbacks/unique_stream_writer.hpp Outdated Show resolved Hide resolved
src/stan/callbacks/json_writer.hpp Outdated Show resolved Hide resolved
src/stan/callbacks/json_writer.hpp Outdated Show resolved Hide resolved
src/stan/callbacks/json_writer.hpp Outdated Show resolved Hide resolved
src/test/unit/callbacks/json_writer_test.cpp Show resolved Hide resolved
src/stan/callbacks/json_writer.hpp Outdated Show resolved Hide resolved
@mitzimorris
Copy link
Member Author

OK, ready for re-review

src/stan/callbacks/unique_stream_writer.hpp Show resolved Hide resolved
src/stan/callbacks/json_writer.hpp Outdated Show resolved Hide resolved
src/test/unit/callbacks/unique_stream_writer_test.cpp Outdated Show resolved Hide resolved
src/test/unit/callbacks/json_writer_test.cpp Outdated Show resolved Hide resolved
@mitzimorris
Copy link
Member Author

looking at write_vector code - if a vector is empty, we should output the empty vector, no? current implementation doesn't.

@mitzimorris
Copy link
Member Author

ready for re-re-review

Copy link
Member

@WardBrian WardBrian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three small things but otherwise I think this is ready. New tests all look great.

src/stan/callbacks/json_writer.hpp Show resolved Hide resolved
src/stan/callbacks/json_writer.hpp Outdated Show resolved Hide resolved
src/stan/callbacks/json_writer.hpp Outdated Show resolved Hide resolved
@bob-carpenter
Copy link
Contributor

The efficient way to do this if you know the instantiations at compile time would be with the CRTP. But I wouldn't do that if the virtual function calls aren't a bottleneck.

@SteveBronder
Copy link
Collaborator

Actually @mitzimorris and @WardBrian one last thing, how should NA and infinite values get handled here? I'm unfamiliar with how json should handle these.

@WardBrian
Copy link
Member

WardBrian commented May 23, 2023

We print them such that the JSON parser we use can read them back in. This involves using some non-standard atoms, since the JSON spec provides no proper format for these:

Value ""JSON""
Not-a-number NaN
Infinity Inf
Negative infinity -Inf

@mitzimorris
Copy link
Member Author

OK to merge?

@WardBrian
Copy link
Member

I think so, @SteveBronder?

@SteveBronder
Copy link
Collaborator

Yep good to merge!

@SteveBronder SteveBronder merged commit 06dc7b2 into develop May 24, 2023
@mitzimorris mitzimorris deleted the feature/3176-json branch March 18, 2024 18:19
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.

6 participants