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

de/serialization issues #2179

Closed
wds15 opened this issue Dec 21, 2016 · 5 comments
Closed

de/serialization issues #2179

wds15 opened this issue Dec 21, 2016 · 5 comments
Labels
Milestone

Comments

@wds15
Copy link
Contributor

wds15 commented Dec 21, 2016

Summary:

When using rstan 2.13 stan_rdump to serialize arrays with zero size , then these cannot be read with cmdstan 2.13

Description:

Serializing with stan_rdump and starting a cmdstan run does not work any more if the arrays has size zero. This used to work with rstan 2.12 and cmdstand 2.12.

This releated to the issue rstan#371 .

Reproducible Steps:

serialized data with rstan 2.13 which does not work with cmdstan 2.13:

N <- 0
y <- 
structure(integer(0), 
.Dim = c(0))

this data works with cmdstan 2.13 and was generated with rstan 2.12:

N <- 0
y <- 
structure(c(),
.Dim = c(0))

Here is a dummy Stan program:

data {
  int N;
  int y[N];
}
parameters {
  real mu;
}
model {
  target += normal_lpdf(mu|0, 1);
}

Current Output:

cmdstan fails to run

Expected Output:

Error from cmdstan:

[weberse2@node04:~/work/stan/misc] ./stan_int_bug sample data file=notok.R

Exception: data y value  beyond int range
Diagnostic information: 
stan_2.13.1/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> >
std::exception::what: data y value  beyond int range

cmdstan Stan Version:

2.13.1

Operating System:

RHEL 6.7

@bob-carpenter
Copy link
Contributor

This issue was moved to stan-dev/rstan#373

@maverickg
Copy link
Contributor

I will try to fix it in stan rather than rstan so all are happy.

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 22, 2016 via email

@maverickg
Copy link
Contributor

see here for why rstan changed this function: stan-dev/rstan#366

The issue is kind of with stan/io/dump.hpp now. In the case of zero length array/matrix/vector, dump in stan depends on a technically wrong behavior of stan_rdump prior to 2.13.2, which outputs zero length array as structure(c(), .Dim = c(1,2,3)). But c() gives NULL in R. So now I think it's better that dump can read data current stan_rdump outputs (examples below).

x <- structure(integer(0), .Dim = c(2, 3, 0))
y <- structure(integer(), .Dim = c(2, 0))
z <- structure(integer(2), .Dim = c(2))
a <- integer()
b <- integer(1)

@bob-carpenter
Copy link
Contributor

Got it. Thanks for re-opening. R never ceases to amaze me:

> c()
NULL

> length(c())
[1] 0

maverickg added a commit that referenced this issue Dec 23, 2016
@syclik syclik added the bug label Dec 26, 2016
@syclik syclik added this to the v2.13.2 milestone Dec 26, 2016
@syclik syclik closed this as completed Dec 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants