https://github.com/stan-dev/stan/wiki/Output-format
I'm ok with doing exploration around suggested libraries but (as you'll see from the JSONlines entry) if I can't think of positives for an option, I won't try very hard. I think we can have this discussion now and settle on a overall strategy soon. I'm on board for implementing something (reasonable in scope) and, as suggested by Daniel, I'm hoping Bob can keep the design to something practical.
It would be great to make this a short-term project so if you have opinions pile on now... (here or at the Wiki page if it's more concrete). Having a good set format and tools to make it compatible with multiple interfaces would make the whole Stan-for-everything strategy a lot easier on interface maintainers.
Krzysztof
We use callbacks everywhere else so they should be fine here too,
but I looked at the JSON parser and did not find any examples of
what the callback "Handler" is supposed to be. Is there an example
somewhere?
>
> When people say CSV here, are we really talking about
> something with the flexibility of an R data frame? That
> is, bunch of columns, each with a data type, then a bunch
> of rows? Are the types just going to be integer, real, bool,
> and string?
I was assuming integer/double but without much type enforcement,
sort of the way we currently write some sampler parameters (e.g.,
tree_depth) as doubles even though they are really integers.
Just looked up SAX parsing and found the abstract base class so it makes sense!
> >> When people say CSV here, are we really talking about
> >> something with the flexibility of an R data frame? That
> >> is, bunch of columns, each with a data type, then a bunch
> >> of rows? Are the types just going to be integer, real, bool,
> >> and string?
> >
> > I was assuming integer/double but without much type enforcement,
> > sort of the way we currently write some sampler parameters (e.g.,
> > tree_depth) as doubles even though they are really integers.
>
> We don't do that in the C++. We promote ints to doubles, but *not*
> vice-versa. It's a disaster for both speed and error handling.
right, we write integers and doubles as doubles. Reading is left to the
interfaces but I'm not sure that we can really say "we don't do that"
when the interfaces have to read in our "int-as-double-as-text" and,
for a column called "n_leapfrog", they have to convert text to int. We
don't have a binary format so I don't think you can blame that on the
interfaces.
>
> R just works the way R works, and it seemed to much of people
> to ask them to explicitly make 1 an integer because R just
> straight-up assumes it's a double if not otherwise informed.
> Our own data parsing does the opposite.
Yeah... R... I'll leave that right there...
So far from the discussion with you and Michael it seems like multiple .csv files with
JSON for the key/value files should be a good overall text format. I'll summarise this
for the Wiki and see what else pops up.
Krzysztof
Even if we just stuck to a semi-standardized binary format the types could
stay coherent. We're not talking about serializing arbitrary C++ classes.
> For R, if you write 1, R's the one that decided
> that should be the same as writing c(1.0); you can coerce it to do something
> else, but it's no longer idiomatic R (and it still trips people up because
> we insist arrays are arrays, but if you pass in just c(1.0), it won't be
> the right type because of the double-duty for scalars and 1D arrays.
>
> >> R just works the way R works, and it seemed to much of people
> >> to ask them to explicitly make 1 an integer because R just
> >> straight-up assumes it's a double if not otherwise informed.
> >> Our own data parsing does the opposite.
> >
> > Yeah... R... I'll leave that right there...
> >
> > So far from the discussion with you and Michael it seems like multiple .csv files with
> > JSON for the key/value files should be a good overall text format. I'll summarise this
> > for the Wiki and see what else pops up.
>
> We can try to accomodate other interfaces other than CmdStan
> with a format that includes the chain ID. I don't think it's
> that much overhead to save, but it would mean a more complicated
> CSV reader.
I'm not sure why the cvs reader would be more complicated. I guess it's special treatment for each value of each row but that seems pretty minor. Am I missing something here?
>
> - Bob
Sigh, I thought one thing and wrote another. I was thinking special treatment for each _first_ value of each row (so key has a known position, no inference necessary). I'm agree 110% with staying clear of type inference. If we're doing anything more complicated with types we should just do binary where you can be clear about it.
Krzysztof
>
> - Bob