alashworth / test-issue-import

0 stars 0 forks source link

support NaN and inf input/output #35

Open alashworth opened 5 years ago

alashworth commented 5 years ago

Issue by bob-carpenter Monday May 05, 2014 at 17:21 GMT Originally opened as https://github.com/stan-dev/stan/issues/637


Our input mechanisms for data and inits should handle NaN and +inf and -inf values.

The new JSON reader handles them for input. But the current R dump format reader, which is the one we're currently using, doesn't. So the dump format should get updated if it's not just eliminated.

alashworth commented 5 years ago

Comment by bob-carpenter Thursday Nov 24, 2016 at 05:40 GMT


See http://stackoverflow.com/questions/11420263/is-it-possible-to-read-infinity-or-nan-values-using-input-streams

Right now, with this program

data {
  real a;
  real b;
  real c;
}
parameters {
  real y;
}
model {
  print("a=", a, "  b=", b, "   c=", c);
  y ~ normal(0, 1);
}

And input dump file

a <- NaN
b <- -inf
c <- 3

it will break reading b because it causes an exception in problem for the initial integer reading pass

> ./is sample data file=is.R

Exception: data b value  beyond int range
Diagnostic information: 
stan/src/stan/io/dump.hpp(518): Throw in function bool stan::io::dump_reader::next()
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::invalid_argument> >
.