-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Internal compiler error: TypeError: a.charCodeAt is not a function #1446
Comments
And can you post the results of the same debugging steps from earlier (calling |
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
0
Internal compiler error:
TypeError: a.charCodeAt is not a function
This should never happen. Please file a bug at https://github.com/stan-dev/stanc3/issues/new
and include this message and the model that caused this issue.
…________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 12:44 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Author ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
And can you post the results of the same debugging steps from earlier (calling stanc on the model code as a string and then on the file)?
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U23CPXHNZMIHWJSR6TZRXCY7AVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGE4DONZQG4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Can you show the full R code that you used? Just so I can be running the same thing
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: tuulam ***@***.***>
Sent: Friday, August 16, 2024 12:55:04 PM
To: stan-dev/stanc3 ***@***.***>
Cc: Andrew Johnson ***@***.***>; Comment ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
0
Internal compiler error:
TypeError: a.charCodeAt is not a function
This should never happen. Please file a bug at https://github.com/stan-dev/stanc3/issues/new
and include this message and the model that caused this issue.
________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 12:44 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Author ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
And can you post the results of the same debugging steps from earlier (calling stanc on the model code as a string and then on the file)?
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U23CPXHNZMIHWJSR6TZRXCY7AVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGE4DONZQG4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGTPCCBOTCXHVCCPBODHJJTZRXD7RAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYDENZSGQ>.
You are receiving this because you commented.Message ID: ***@***.***>
|
lambda_true = 3
N = 5
set.seed(111111)
(y = rpois(N, lambda_true))
poisson_dat = list(y = y, N = N)
alpha = beta = 1
fit2 <- stan('poisson_lognormal.stan', poisson_dat, iter = 20000, chains = 4)
The stan file is the following
data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real<lower=0> lambda;
}
model {
lambda ~ lognormal(0,1);
y ~ poisson(lambda);
}
…________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 12:56 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Author ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
Can you show the full R code that you used? Just so I can be running the same thing
Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: tuulam ***@***.***>
Sent: Friday, August 16, 2024 12:55:04 PM
To: stan-dev/stanc3 ***@***.***>
Cc: Andrew Johnson ***@***.***>; Comment ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
0
Internal compiler error:
TypeError: a.charCodeAt is not a function
This should never happen. Please file a bug at https://github.com/stan-dev/stanc3/issues/new
and include this message and the model that caused this issue.
________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 12:44 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Author ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
And can you post the results of the same debugging steps from earlier (calling stanc on the model code as a string and then on the file)?
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U23CPXHNZMIHWJSR6TZRXCY7AVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGE4DONZQG4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGTPCCBOTCXHVCCPBODHJJTZRXD7RAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYDENZSGQ>.
You are receiving this because you commented.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U35OX4475CSCSELQ7DZRXEFXAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYDKNBVG4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
And can you do the same for running stanc on the model as a string? (The full R code and the results) |
I am not sure what I am supposed to do. I created a string
m = str('{data {
+ int<lower=0> N;
+ array[N] int<lower=0> y;
+ }
+
+ parameters {
+ real<lower=0> lambda;
+ }
+ model {
+ lambda ~ lognormal(0,1);
+ y ~ poisson(lambda);
+ }')
and ran
stanc(fit2 <- stan('poisson_lognormal.stan', m, iter = 20000, chains = 4))
I got an error message:
Error : Exception: variable does not exist; processing stage=data initialization; variable name=N; base type=int (in 'string', line 2, column 1 to column 16)
failed to create the sampler; sampling not done
Error in isTRUE(!nzchar(file)) :
no method for coercing this S4 class to a vector
…________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 1:02 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Author ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
lambda_true = 3
N = 5
set.seed(111111)
(y = rpois(N, lambda_true))
poisson_dat = list(y = y, N = N)
alpha = beta = 1
fit2 <- stan('poisson_lognormal.stan', poisson_dat, iter = 20000, chains = 4)
The stan file is the following
data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real<lower=0> lambda;
}
model {
lambda ~ lognormal(0,1);
y ~ poisson(lambda);
}
________________________________
From: Andrew Johnson @.>
Sent: Friday, August 16, 2024 12:56 PM
To: stan-dev/stanc3 @.>
Cc: tuulam @.>; Author @.>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446<#1446>)
Can you show the full R code that you used? Just so I can be running the same thing
Get Outlook for Androidhttps://aka.ms/AAb9ysg
________________________________
From: tuulam @.>
Sent: Friday, August 16, 2024 12:55:04 PM
To: stan-dev/stanc3 @.>
Cc: Andrew Johnson @.>; Comment @.>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446<#1446>)
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
0
Internal compiler error:
TypeError: a.charCodeAt is not a function
This should never happen. Please file a bug at https://github.com/stan-dev/stanc3/issues/new
and include this message and the model that caused this issue.
________________________________
From: Andrew Johnson @.>
Sent: Friday, August 16, 2024 12:44 PM
To: stan-dev/stanc3 @.>
Cc: tuulam @.>; Author @.>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446<#1446>)
And can you post the results of the same debugging steps from earlier (calling stanc on the model code as a string and then on the file)?
—
Reply to this email directly, view it on GitHub#1446 (comment)<#1446 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALZZ4U23CPXHNZMIHWJSR6TZRXCY7AVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGE4DONZQG4.
You are receiving this because you authored the thread.Message ID: @.***>
—
Reply to this email directly, view it on GitHub#1446 (comment)<#1446 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGTPCCBOTCXHVCCPBODHJJTZRXD7RAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYDENZSGQ.
You are receiving this because you commented.Message ID: @.***>
—
Reply to this email directly, view it on GitHub#1446 (comment)<#1446 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALZZ4U35OX4475CSCSELQ7DZRXEFXAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYDKNBVG4.
You are receiving this because you authored the thread.Message ID: @.***>
And can you do the same for running stanc on the model as a string? (The full R code and the results)
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U47TTLXYB2KLUN7H6TZRXE25AVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIYTMMZSGQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Like the following: stancode <- "YOUR MODEL CODE"
rstan::stanc(model_code=stancode) |
What do you mean by model code, the stan-file, or fit-function?
…On Fri, 16 Aug 2024 at 13:15, Andrew Johnson ***@***.***> wrote:
I am not sure what I am supposed to do.
Like the following:
stancode <- "YOUR MODEL CODE"rstan::stanc(model_code=stanc)
—
Reply to this email directly, view it on GitHub
<#1446 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALZZ4U6PNX57EMS6ZXW43K3ZRXGK3AVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGIZTMNJQGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
If your model is: data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real<lower=0> lambda;
}
model {
lambda ~ lognormal(0,1);
y ~ poisson(lambda);
} Then run: stancode <- "
data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real<lower=0> lambda;
}
model {
lambda ~ lognormal(0,1);
y ~ poisson(lambda);
}
"
rstan::stanc(model_code=stancode) And post the R code you used and the result |
________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 2:33 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Author ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
If your model is:
data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real<lower=0> lambda;
}
model {
lambda ~ lognormal(0,1);
y ~ poisson(lambda);
}
Then run:
stancode <- "
data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real<lower=0> lambda;
}
model {
lambda ~ lognormal(0,1);
y ~ poisson(lambda);
}
"
rstan::stanc(model_code=stancode)
And post the R code you used and the result
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U7ZZHTIN7QE4XR7F2LZRXPPNAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGM2DAMBTGQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Hi @tuulam -- your last reply seems to be blank. Could you send the output again? |
On Fri, 16 Aug 2024 at 17:36, Brian Ward ***@***.***> wrote:
Hi @tuulam <https://github.com/tuulam> -- your last reply seems to be
blank. Could you send the output again?
—
Reply to this email directly, view it on GitHub
<#1446 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALZZ4U4JDDHJBR7YFE5WMVTZRYE6VAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGYZDQOBUHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
stancode <- "
+ data {
+ int<lower=0> N;
+ array[N] int<lower=0> y;
+ }
+
+ parameters {
+ real<lower=0> lambda;
+ }
+ model {
+ lambda ~ lognormal(0,1);
+ y ~ poisson(lambda);
+ }
+ "
rstan::stanc(model_code=stancode)
$status
[1] TRUE
$model_cppname
[1] "model38d83c842f2_file38d8327b67a4"
$cppcode
[1] "#ifndef USE_STANC3\n#define USE_STANC3\n#endif\n// Code generated by stanc v2.35.0\n#include <stan/model/model_header.hpp>\nnamespace model38d83c842f2_file38d8327b67a4_namespace {\nusing stan::model::model_base_crtp;\nusing namespace stan::math;\nstan::math::profile_map profiles__;\nstatic constexpr std::array<const char*, 7> locations_array__ =\n {\" (found before start of program)\",\n \" (in 'string', line 6, column 0 to column 21)\",\n \" (in 'string', line 9, column 0 to column 24)\",\n \" (in 'string', line 10, column 0 to column 20)\",\n \" (in 'string', line 2, column 0 to column 15)\",\n \" (in 'string', line 3, column 6 to column 7)\",\n \" (in 'string', line 3, column 0 to column 24)\"};\nclass model38d83c842f2_file38d8327b67a4 final : public model_base_crtp<model38d83c842f2_file38d8327b67a4> {\nprivate:\n int N;\n std::vector<int> y;\npublic:\n ~model38d83c842f2_file38d8327b67a4() {}\n model38d83c842f2_file38d8327b67a4(stan::io::var_context& context__,\n unsigned int random_seed__ = 0,\n std::ostream* pstream__ = nullptr)\n : model_base_crtp(0) {\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n using local_scalar_t__ = double;\n auto base_rng__ = stan::services::util::create_rng(random_seed__, 0);\n // suppress unused var warning\n (void) base_rng__;\n static constexpr const char* function__ =\n \"model38d83c842f2_file38d8327b67a4_namespace::model38d83c842f2_file38d8327b67a4\";\n // suppress unused var warning\n (void) function__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n try {\n current_statement__ = 4;\n context__.validate_dims(\"data initialization\", \"N\", \"int\",\n std::vector<size_t>{});\n N = std::numeric_limits<int>::min();\n current_statement__ = 4;\n N = context__.vals_i(\"N\")[(1 - 1)];\n current_statement__ = 4;\n stan::math::check_greater_or_equal(function__, \"N\", N, 0);\n current_statement__ = 5;\n stan::math::validate_non_negative_index(\"y\", \"N\", N);\n current_statement__ = 6;\n context__.validate_dims(\"data initialization\", \"y\", \"int\",\n std::vector<size_t>{static_cast<size_t>(N)});\n y = std::vector<int>(N, std::numeric_limits<int>::min());\n current_statement__ = 6;\n y = context__.vals_i(\"y\");\n current_statement__ = 6;\n stan::math::check_greater_or_equal(function__, \"y\", y, 0);\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n num_params_r__ = 1;\n }\n inline std::string model_name() const final {\n return \"model38d83c842f2_file38d8327b67a4\";\n }\n inline std::vector<std::string> model_compile_info() const noexcept {\n return std::vector<std::string>{\"stanc_version = stanc3 v2.35.0\",\n \"stancflags = --\"};\n }\n // Base log prob\n template <bool propto__, bool jacobian__, typename VecR, typename VecI,\n stan::require_vector_like_t<VecR>* = nullptr,\n stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr,\n stan::require_not_st_var<VecR>* = nullptr>\n inline stan::scalar_type_t<VecR>\n log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream*\n pstream__ = nullptr) const {\n using T__ = stan::scalar_type_t<VecR>;\n using local_scalar_t__ = T__;\n T__ lp__(0.0);\n stan::math::accumulator<T__> lp_accum__;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n static constexpr const char* function__ =\n \"model38d83c842f2_file38d8327b67a4_namespace::log_prob\";\n // suppress unused var warning\n (void) function__;\n try {\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = in__.template read_constrain_lb<local_scalar_t__,\n jacobian__>(0, lp__);\n {\n current_statement__ = 2;\n lp_accum__.add(stan::math::lognormal_lpdf<propto__>(lambda, 0, 1));\n current_statement__ = 3;\n lp_accum__.add(stan::math::poisson_lpmf<propto__>(y, lambda));\n }\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n lp_accum__.add(lp__);\n return lp_accum__.sum();\n }\n // Reverse mode autodiff log prob\n template <bool propto__, bool jacobian__, typename VecR, typename VecI,\n stan::require_vector_like_t<VecR>* = nullptr,\n stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr,\n stan::require_st_var<VecR>* = nullptr>\n inline stan::scalar_type_t<VecR>\n log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream*\n pstream__ = nullptr) const {\n using T__ = stan::scalar_type_t<VecR>;\n using local_scalar_t__ = T__;\n T__ lp__(0.0);\n stan::math::accumulator<T__> lp_accum__;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n static constexpr const char* function__ =\n \"model38d83c842f2_file38d8327b67a4_namespace::log_prob\";\n // suppress unused var warning\n (void) function__;\n try {\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = in__.template read_constrain_lb<local_scalar_t__,\n jacobian__>(0, lp__);\n {\n current_statement__ = 2;\n lp_accum__.add(stan::math::lognormal_lpdf<propto__>(lambda, 0, 1));\n current_statement__ = 3;\n lp_accum__.add(stan::math::poisson_lpmf<propto__>(y, lambda));\n }\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n lp_accum__.add(lp__);\n return lp_accum__.sum();\n }\n template <typename RNG, typename VecR, typename VecI, typename VecVar,\n stan::require_vector_like_vt<std::is_floating_point,\n VecR>* = nullptr, stan::require_vector_like_vt<std::is_integral,\n VecI>* = nullptr, stan::require_vector_vt<std::is_floating_point,\n VecVar>* = nullptr>\n inline void\n write_array_impl(RNG& base_rng__, VecR& params_r__, VecI& params_i__,\n VecVar& vars__, const bool\n emit_transformed_parameters__ = true, const bool\n emit_generated_quantities__ = true, std::ostream*\n pstream__ = nullptr) const {\n using local_scalar_t__ = double;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n stan::io::serializer<local_scalar_t__> out__(vars__);\n static constexpr bool propto__ = true;\n // suppress unused var warning\n (void) propto__;\n double lp__ = 0.0;\n // suppress unused var warning\n (void) lp__;\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n stan::math::accumulator<double> lp_accum__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n constexpr bool jacobian__ = false;\n // suppress unused var warning\n (void) jacobian__;\n static constexpr const char* function__ =\n \"model38d83c842f2_file38d8327b67a4_namespace::write_array\";\n // suppress unused var warning\n (void) function__;\n try {\n double lambda = std::numeric_limits<double>::quiet_NaN();\n current_statement__ = 1;\n lambda = in__.template read_constrain_lb<local_scalar_t__,\n jacobian__>(0, lp__);\n out__.write(lambda);\n if (stan::math::logical_negation(\n (stan::math::primitive_value(emit_transformed_parameters__) ||\n stan::math::primitive_value(emit_generated_quantities__)))) {\n return ;\n }\n if (stan::math::logical_negation(emit_generated_quantities__)) {\n return ;\n }\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n }\n template <typename VecVar, typename VecI,\n stan::require_vector_t<VecVar>* = nullptr,\n stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>\n inline void\n unconstrain_array_impl(const VecVar& params_r__, const VecI& params_i__,\n VecVar& vars__, std::ostream* pstream__ = nullptr) const {\n using local_scalar_t__ = double;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n stan::io::serializer<local_scalar_t__> out__(vars__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n try {\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = in__.read<local_scalar_t__>();\n out__.write_free_lb(0, lambda);\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n }\n template <typename VecVar, stan::require_vector_t<VecVar>* = nullptr>\n inline void\n transform_inits_impl(const stan::io::var_context& context__, VecVar&\n vars__, std::ostream* pstream__ = nullptr) const {\n using local_scalar_t__ = double;\n stan::io::serializer<local_scalar_t__> out__(vars__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n try {\n current_statement__ = 1;\n context__.validate_dims(\"parameter initialization\", \"lambda\", \"double\",\n std::vector<size_t>{});\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = context__.vals_r(\"lambda\")[(1 - 1)];\n out__.write_free_lb(0, lambda);\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n }\n inline void\n get_param_names(std::vector<std::string>& names__, const bool\n emit_transformed_parameters__ = true, const bool\n emit_generated_quantities__ = true) const {\n names__ = std::vector<std::string>{\"lambda\"};\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline void\n get_dims(std::vector<std::vector<size_t>>& dimss__, const bool\n emit_transformed_parameters__ = true, const bool\n emit_generated_quantities__ = true) const {\n dimss__ = std::vector<std::vector<size_t>>{std::vector<size_t>{}};\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline void\n constrained_param_names(std::vector<std::string>& param_names__, bool\n emit_transformed_parameters__ = true, bool\n emit_generated_quantities__ = true) const final {\n param_names__.emplace_back(std::string() + \"lambda\");\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline void\n unconstrained_param_names(std::vector<std::string>& param_names__, bool\n emit_transformed_parameters__ = true, bool\n emit_generated_quantities__ = true) const final {\n param_names__.emplace_back(std::string() + \"lambda\");\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline std::string get_constrained_sizedtypes() const {\n return std::string(\"[{\\\"name\\\":\\\"lambda\\\",\\\"type\\\":{\\\"name\\\":\\\"real\\\"},\\\"block\\\":\\\"parameters\\\"}]\");\n }\n inline std::string get_unconstrained_sizedtypes() const {\n return std::string(\"[{\\\"name\\\":\\\"lambda\\\",\\\"type\\\":{\\\"name\\\":\\\"real\\\"},\\\"block\\\":\\\"parameters\\\"}]\");\n }\n // Begin method overload boilerplate\n template <typename RNG> inline void\n write_array(RNG& base_rng, Eigen::Matrix<double,-1,1>& params_r,\n Eigen::Matrix<double,-1,1>& vars, const bool\n emit_transformed_parameters = true, const bool\n emit_generated_quantities = true, std::ostream*\n pstream = nullptr) const {\n const size_t num_params__ = 1;\n const size_t num_transformed = emit_transformed_parameters * (0);\n const size_t num_gen_quantities = emit_generated_quantities * (0);\n const size_t num_to_write = num_params__ + num_transformed +\n num_gen_quantities;\n std::vector<int> params_i;\n vars = Eigen::Matrix<double,-1,1>::Constant(num_to_write,\n std::numeric_limits<double>::quiet_NaN());\n write_array_impl(base_rng, params_r, params_i, vars,\n emit_transformed_parameters, emit_generated_quantities, pstream);\n }\n template <typename RNG> inline void\n write_array(RNG& base_rng, std::vector<double>& params_r, std::vector<int>&\n params_i, std::vector<double>& vars, bool\n emit_transformed_parameters = true, bool\n emit_generated_quantities = true, std::ostream*\n pstream = nullptr) const {\n const size_t num_params__ = 1;\n const size_t num_transformed = emit_transformed_parameters * (0);\n const size_t num_gen_quantities = emit_generated_quantities * (0);\n const size_t num_to_write = num_params__ + num_transformed +\n num_gen_quantities;\n vars = std::vector<double>(num_to_write,\n std::numeric_limits<double>::quiet_NaN());\n write_array_impl(base_rng, params_r, params_i, vars,\n emit_transformed_parameters, emit_generated_quantities, pstream);\n }\n template <bool propto__, bool jacobian__, typename T_> inline T_\n log_prob(Eigen::Matrix<T_,-1,1>& params_r, std::ostream* pstream = nullptr) const {\n Eigen::Matrix<int,-1,1> params_i;\n return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);\n }\n template <bool propto__, bool jacobian__, typename T_> inline T_\n log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,\n std::ostream* pstream = nullptr) const {\n return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);\n }\n inline void\n transform_inits(const stan::io::var_context& context,\n Eigen::Matrix<double,-1,1>& params_r, std::ostream*\n pstream = nullptr) const final {\n std::vector<double> params_r_vec(params_r.size());\n std::vector<int> params_i;\n transform_inits(context, params_i, params_r_vec, pstream);\n params_r = Eigen::Map<Eigen::Matrix<double,-1,1>>(params_r_vec.data(),\n params_r_vec.size());\n }\n inline void\n transform_inits(const stan::io::var_context& context, std::vector<int>&\n params_i, std::vector<double>& vars, std::ostream*\n pstream__ = nullptr) const {\n vars.resize(num_params_r__);\n transform_inits_impl(context, vars, pstream__);\n }\n inline void\n unconstrain_array(const std::vector<double>& params_constrained,\n std::vector<double>& params_unconstrained, std::ostream*\n pstream = nullptr) const {\n const std::vector<int> params_i;\n params_unconstrained = std::vector<double>(num_params_r__,\n std::numeric_limits<double>::quiet_NaN());\n unconstrain_array_impl(params_constrained, params_i,\n params_unconstrained, pstream);\n }\n inline void\n unconstrain_array(const Eigen::Matrix<double,-1,1>& params_constrained,\n Eigen::Matrix<double,-1,1>& params_unconstrained,\n std::ostream* pstream = nullptr) const {\n const std::vector<int> params_i;\n params_unconstrained = Eigen::Matrix<double,-1,1>::Constant(num_params_r__,\n std::numeric_limits<double>::quiet_NaN());\n unconstrain_array_impl(params_constrained, params_i,\n params_unconstrained, pstream);\n }\n};\n}\nusing stan_model = model38d83c842f2_file38d8327b67a4_namespace::model38d83c842f2_file38d8327b67a4;\n#ifndef USING_R\n// Boilerplate\nstan::model::model_base&\nnew_model(stan::io::var_context& data_context, unsigned int seed,\n std::ostream* msg_stream) {\n stan_model* m = new stan_model(data_context, seed, msg_stream);\n return *m;\n}\nstan::math::profile_map& get_stan_profile_data() {\n return model38d83c842f2_file38d8327b67a4_namespace::profiles__;\n}\n#endif"
$model_name
[1] "file38d8327b67a4"
$model_code
[1] "data {\nint<lower=0> N;\narray[N] int<lower=0> y;\n}\nparameters {\nreal<lower=0> lambda;\n}\nmodel {\nlambda ~ lognormal(0,1);\ny ~ poisson(lambda);\n}"
attr(,"model_name2")
[1] "file38d8327b67a4"
|
That indicates no error, are you still getting the error with your Stan file? |
Unfortunately, yes I do.
…________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 8:57 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Mention ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
That indicates no error, are you still getting the error with your Stan file?
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U4V4ULENJMOJ2ZZ6S3ZRY4PNAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTHEZDIOJXGM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Interesting! Can you run: cat("poisson_lognormal.stan", sep="\n")
rstan::stanc(file="poisson_lognormal.stan") |
Oops, that should be: |
On Fri, 16 Aug 2024 at 21:08, Andrew Johnson ***@***.***> wrote:
cat("poisson_lognormal.stan", sep="\n")
Oops, that should be: readLines("poisson_lognormal.stan") instead
—
Reply to this email directly, view it on GitHub
<#1446 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALZZ4U3BLBF3ICHKCOIS2U3ZRY5ZXAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTHEZTSNJWGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
readLines("poisson_lognormal.stan")
[1] "data {" "\tint<lower=0> N;" "\tarray[N] int<lower=0> y;"
[4] "}" "" "parameters {"
[7] "\treal<lower=0> lambda;" "}" "model {"
[10] "\tlambda ~ lognormal(0,1);" "\ty ~ poisson(lambda);" "}"
rstan::stanc(file="poisson_lognormal.stan")
$status
[1] TRUE
$model_cppname
[1] "model38d81c9023cf_poisson_lognormal"
$cppcode
[1] "#ifndef USE_STANC3\n#define USE_STANC3\n#endif\n// Code generated by stanc v2.35.0\n#include <stan/model/model_header.hpp>\nnamespace model38d81c9023cf_poisson_lognormal_namespace {\nusing stan::model::model_base_crtp;\nusing namespace stan::math;\nstan::math::profile_map profiles__;\nstatic constexpr std::array<const char*, 7> locations_array__ =\n {\" (found before start of program)\",\n \" (in 'string', line 6, column 1 to column 22)\",\n \" (in 'string', line 9, column 1 to column 25)\",\n \" (in 'string', line 10, column 1 to column 21)\",\n \" (in 'string', line 2, column 1 to column 16)\",\n \" (in 'string', line 3, column 7 to column 8)\",\n \" (in 'string', line 3, column 1 to column 25)\"};\nclass model38d81c9023cf_poisson_lognormal final : public model_base_crtp<model38d81c9023cf_poisson_lognormal> {\nprivate:\n int N;\n std::vector<int> y;\npublic:\n ~model38d81c9023cf_poisson_lognormal() {}\n model38d81c9023cf_poisson_lognormal(stan::io::var_context& context__,\n unsigned int random_seed__ = 0,\n std::ostream* pstream__ = nullptr)\n : model_base_crtp(0) {\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n using local_scalar_t__ = double;\n auto base_rng__ = stan::services::util::create_rng(random_seed__, 0);\n // suppress unused var warning\n (void) base_rng__;\n static constexpr const char* function__ =\n \"model38d81c9023cf_poisson_lognormal_namespace::model38d81c9023cf_poisson_lognormal\";\n // suppress unused var warning\n (void) function__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n try {\n current_statement__ = 4;\n context__.validate_dims(\"data initialization\", \"N\", \"int\",\n std::vector<size_t>{});\n N = std::numeric_limits<int>::min();\n current_statement__ = 4;\n N = context__.vals_i(\"N\")[(1 - 1)];\n current_statement__ = 4;\n stan::math::check_greater_or_equal(function__, \"N\", N, 0);\n current_statement__ = 5;\n stan::math::validate_non_negative_index(\"y\", \"N\", N);\n current_statement__ = 6;\n context__.validate_dims(\"data initialization\", \"y\", \"int\",\n std::vector<size_t>{static_cast<size_t>(N)});\n y = std::vector<int>(N, std::numeric_limits<int>::min());\n current_statement__ = 6;\n y = context__.vals_i(\"y\");\n current_statement__ = 6;\n stan::math::check_greater_or_equal(function__, \"y\", y, 0);\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n num_params_r__ = 1;\n }\n inline std::string model_name() const final {\n return \"model38d81c9023cf_poisson_lognormal\";\n }\n inline std::vector<std::string> model_compile_info() const noexcept {\n return std::vector<std::string>{\"stanc_version = stanc3 v2.35.0\",\n \"stancflags = --\"};\n }\n // Base log prob\n template <bool propto__, bool jacobian__, typename VecR, typename VecI,\n stan::require_vector_like_t<VecR>* = nullptr,\n stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr,\n stan::require_not_st_var<VecR>* = nullptr>\n inline stan::scalar_type_t<VecR>\n log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream*\n pstream__ = nullptr) const {\n using T__ = stan::scalar_type_t<VecR>;\n using local_scalar_t__ = T__;\n T__ lp__(0.0);\n stan::math::accumulator<T__> lp_accum__;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n static constexpr const char* function__ =\n \"model38d81c9023cf_poisson_lognormal_namespace::log_prob\";\n // suppress unused var warning\n (void) function__;\n try {\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = in__.template read_constrain_lb<local_scalar_t__,\n jacobian__>(0, lp__);\n {\n current_statement__ = 2;\n lp_accum__.add(stan::math::lognormal_lpdf<propto__>(lambda, 0, 1));\n current_statement__ = 3;\n lp_accum__.add(stan::math::poisson_lpmf<propto__>(y, lambda));\n }\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n lp_accum__.add(lp__);\n return lp_accum__.sum();\n }\n // Reverse mode autodiff log prob\n template <bool propto__, bool jacobian__, typename VecR, typename VecI,\n stan::require_vector_like_t<VecR>* = nullptr,\n stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr,\n stan::require_st_var<VecR>* = nullptr>\n inline stan::scalar_type_t<VecR>\n log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream*\n pstream__ = nullptr) const {\n using T__ = stan::scalar_type_t<VecR>;\n using local_scalar_t__ = T__;\n T__ lp__(0.0);\n stan::math::accumulator<T__> lp_accum__;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n static constexpr const char* function__ =\n \"model38d81c9023cf_poisson_lognormal_namespace::log_prob\";\n // suppress unused var warning\n (void) function__;\n try {\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = in__.template read_constrain_lb<local_scalar_t__,\n jacobian__>(0, lp__);\n {\n current_statement__ = 2;\n lp_accum__.add(stan::math::lognormal_lpdf<propto__>(lambda, 0, 1));\n current_statement__ = 3;\n lp_accum__.add(stan::math::poisson_lpmf<propto__>(y, lambda));\n }\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n lp_accum__.add(lp__);\n return lp_accum__.sum();\n }\n template <typename RNG, typename VecR, typename VecI, typename VecVar,\n stan::require_vector_like_vt<std::is_floating_point,\n VecR>* = nullptr, stan::require_vector_like_vt<std::is_integral,\n VecI>* = nullptr, stan::require_vector_vt<std::is_floating_point,\n VecVar>* = nullptr>\n inline void\n write_array_impl(RNG& base_rng__, VecR& params_r__, VecI& params_i__,\n VecVar& vars__, const bool\n emit_transformed_parameters__ = true, const bool\n emit_generated_quantities__ = true, std::ostream*\n pstream__ = nullptr) const {\n using local_scalar_t__ = double;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n stan::io::serializer<local_scalar_t__> out__(vars__);\n static constexpr bool propto__ = true;\n // suppress unused var warning\n (void) propto__;\n double lp__ = 0.0;\n // suppress unused var warning\n (void) lp__;\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n stan::math::accumulator<double> lp_accum__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n constexpr bool jacobian__ = false;\n // suppress unused var warning\n (void) jacobian__;\n static constexpr const char* function__ =\n \"model38d81c9023cf_poisson_lognormal_namespace::write_array\";\n // suppress unused var warning\n (void) function__;\n try {\n double lambda = std::numeric_limits<double>::quiet_NaN();\n current_statement__ = 1;\n lambda = in__.template read_constrain_lb<local_scalar_t__,\n jacobian__>(0, lp__);\n out__.write(lambda);\n if (stan::math::logical_negation(\n (stan::math::primitive_value(emit_transformed_parameters__) ||\n stan::math::primitive_value(emit_generated_quantities__)))) {\n return ;\n }\n if (stan::math::logical_negation(emit_generated_quantities__)) {\n return ;\n }\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n }\n template <typename VecVar, typename VecI,\n stan::require_vector_t<VecVar>* = nullptr,\n stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>\n inline void\n unconstrain_array_impl(const VecVar& params_r__, const VecI& params_i__,\n VecVar& vars__, std::ostream* pstream__ = nullptr) const {\n using local_scalar_t__ = double;\n stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);\n stan::io::serializer<local_scalar_t__> out__(vars__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n try {\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = in__.read<local_scalar_t__>();\n out__.write_free_lb(0, lambda);\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n }\n template <typename VecVar, stan::require_vector_t<VecVar>* = nullptr>\n inline void\n transform_inits_impl(const stan::io::var_context& context__, VecVar&\n vars__, std::ostream* pstream__ = nullptr) const {\n using local_scalar_t__ = double;\n stan::io::serializer<local_scalar_t__> out__(vars__);\n int current_statement__ = 0;\n // suppress unused var warning\n (void) current_statement__;\n local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());\n // suppress unused var warning\n (void) DUMMY_VAR__;\n try {\n current_statement__ = 1;\n context__.validate_dims(\"parameter initialization\", \"lambda\", \"double\",\n std::vector<size_t>{});\n local_scalar_t__ lambda = DUMMY_VAR__;\n current_statement__ = 1;\n lambda = context__.vals_r(\"lambda\")[(1 - 1)];\n out__.write_free_lb(0, lambda);\n } catch (const std::exception& e) {\n stan::lang::rethrow_located(e, locations_array__[current_statement__]);\n }\n }\n inline void\n get_param_names(std::vector<std::string>& names__, const bool\n emit_transformed_parameters__ = true, const bool\n emit_generated_quantities__ = true) const {\n names__ = std::vector<std::string>{\"lambda\"};\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline void\n get_dims(std::vector<std::vector<size_t>>& dimss__, const bool\n emit_transformed_parameters__ = true, const bool\n emit_generated_quantities__ = true) const {\n dimss__ = std::vector<std::vector<size_t>>{std::vector<size_t>{}};\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline void\n constrained_param_names(std::vector<std::string>& param_names__, bool\n emit_transformed_parameters__ = true, bool\n emit_generated_quantities__ = true) const final {\n param_names__.emplace_back(std::string() + \"lambda\");\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline void\n unconstrained_param_names(std::vector<std::string>& param_names__, bool\n emit_transformed_parameters__ = true, bool\n emit_generated_quantities__ = true) const final {\n param_names__.emplace_back(std::string() + \"lambda\");\n if (emit_transformed_parameters__) {}\n if (emit_generated_quantities__) {}\n }\n inline std::string get_constrained_sizedtypes() const {\n return std::string(\"[{\\\"name\\\":\\\"lambda\\\",\\\"type\\\":{\\\"name\\\":\\\"real\\\"},\\\"block\\\":\\\"parameters\\\"}]\");\n }\n inline std::string get_unconstrained_sizedtypes() const {\n return std::string(\"[{\\\"name\\\":\\\"lambda\\\",\\\"type\\\":{\\\"name\\\":\\\"real\\\"},\\\"block\\\":\\\"parameters\\\"}]\");\n }\n // Begin method overload boilerplate\n template <typename RNG> inline void\n write_array(RNG& base_rng, Eigen::Matrix<double,-1,1>& params_r,\n Eigen::Matrix<double,-1,1>& vars, const bool\n emit_transformed_parameters = true, const bool\n emit_generated_quantities = true, std::ostream*\n pstream = nullptr) const {\n const size_t num_params__ = 1;\n const size_t num_transformed = emit_transformed_parameters * (0);\n const size_t num_gen_quantities = emit_generated_quantities * (0);\n const size_t num_to_write = num_params__ + num_transformed +\n num_gen_quantities;\n std::vector<int> params_i;\n vars = Eigen::Matrix<double,-1,1>::Constant(num_to_write,\n std::numeric_limits<double>::quiet_NaN());\n write_array_impl(base_rng, params_r, params_i, vars,\n emit_transformed_parameters, emit_generated_quantities, pstream);\n }\n template <typename RNG> inline void\n write_array(RNG& base_rng, std::vector<double>& params_r, std::vector<int>&\n params_i, std::vector<double>& vars, bool\n emit_transformed_parameters = true, bool\n emit_generated_quantities = true, std::ostream*\n pstream = nullptr) const {\n const size_t num_params__ = 1;\n const size_t num_transformed = emit_transformed_parameters * (0);\n const size_t num_gen_quantities = emit_generated_quantities * (0);\n const size_t num_to_write = num_params__ + num_transformed +\n num_gen_quantities;\n vars = std::vector<double>(num_to_write,\n std::numeric_limits<double>::quiet_NaN());\n write_array_impl(base_rng, params_r, params_i, vars,\n emit_transformed_parameters, emit_generated_quantities, pstream);\n }\n template <bool propto__, bool jacobian__, typename T_> inline T_\n log_prob(Eigen::Matrix<T_,-1,1>& params_r, std::ostream* pstream = nullptr) const {\n Eigen::Matrix<int,-1,1> params_i;\n return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);\n }\n template <bool propto__, bool jacobian__, typename T_> inline T_\n log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,\n std::ostream* pstream = nullptr) const {\n return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);\n }\n inline void\n transform_inits(const stan::io::var_context& context,\n Eigen::Matrix<double,-1,1>& params_r, std::ostream*\n pstream = nullptr) const final {\n std::vector<double> params_r_vec(params_r.size());\n std::vector<int> params_i;\n transform_inits(context, params_i, params_r_vec, pstream);\n params_r = Eigen::Map<Eigen::Matrix<double,-1,1>>(params_r_vec.data(),\n params_r_vec.size());\n }\n inline void\n transform_inits(const stan::io::var_context& context, std::vector<int>&\n params_i, std::vector<double>& vars, std::ostream*\n pstream__ = nullptr) const {\n vars.resize(num_params_r__);\n transform_inits_impl(context, vars, pstream__);\n }\n inline void\n unconstrain_array(const std::vector<double>& params_constrained,\n std::vector<double>& params_unconstrained, std::ostream*\n pstream = nullptr) const {\n const std::vector<int> params_i;\n params_unconstrained = std::vector<double>(num_params_r__,\n std::numeric_limits<double>::quiet_NaN());\n unconstrain_array_impl(params_constrained, params_i,\n params_unconstrained, pstream);\n }\n inline void\n unconstrain_array(const Eigen::Matrix<double,-1,1>& params_constrained,\n Eigen::Matrix<double,-1,1>& params_unconstrained,\n std::ostream* pstream = nullptr) const {\n const std::vector<int> params_i;\n params_unconstrained = Eigen::Matrix<double,-1,1>::Constant(num_params_r__,\n std::numeric_limits<double>::quiet_NaN());\n unconstrain_array_impl(params_constrained, params_i,\n params_unconstrained, pstream);\n }\n};\n}\nusing stan_model = model38d81c9023cf_poisson_lognormal_namespace::model38d81c9023cf_poisson_lognormal;\n#ifndef USING_R\n// Boilerplate\nstan::model::model_base&\nnew_model(stan::io::var_context& data_context, unsigned int seed,\n std::ostream* msg_stream) {\n stan_model* m = new stan_model(data_context, seed, msg_stream);\n return *m;\n}\nstan::math::profile_map& get_stan_profile_data() {\n return model38d81c9023cf_poisson_lognormal_namespace::profiles__;\n}\n#endif"
$model_name
[1] "poisson_lognormal"
$model_code
[1] "data {\n\tint<lower=0> N;\n\tarray[N] int<lower=0> y;\n}\nparameters {\n\treal<lower=0> lambda;\n}\nmodel {\n\tlambda ~ lognormal(0,1);\n\ty ~ poisson(lambda);\n}"
attr(,"model_name2")
[1] "poisson_lognormal"
|
Hmm also no error there, and if you run: rstan::stan("poisson_lognormal.stan", data = list(N=1, y=1)) |
rstan::stan("poisson_lognormal.stan", data = list(N=1, y=1))Error : Exception: mismatch in number dimensions declared and found in context; processing stage=data initialization; variable name=y; dims declared=(1); dims found=() (in 'string', line 3, column 1 to column 25)
failed to create the sampler; sampling not done
…
On Fri, 16 Aug 2024 at 21:23, Andrew Johnson ***@***.***> wrote:
Hmm also no error there, and if you run:
rstan::stan("poisson_lognormal.stan", data = list(N=1, y=1))
—
Reply to this email directly, view it on GitHub
<#1446 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALZZ4U7IDOJYWWBSQP4FNWTZRY7THAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTHE3DAMJSGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Ah, try this instead: rstan::stan("poisson_lognormal.stan", data = list(N=2, y=c(1, 2))) |
On Fri, 16 Aug 2024 at 21:28, Andrew Johnson ***@***.***> wrote:
Ah, try this instead:
rstan::stan("poisson_lognormal.stan", data = list(N=2, y=c(1, 2)))
—
Reply to this email directly, view it on GitHub
<#1446 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALZZ4U63VKLV2XIE4RWF2BDZRZADDAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTHE3DKOJUGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
rstan::stan("poisson_lognormal.stan", data = list(N=2, y=c(1, 2)))
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0.00046 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 4.6 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 0.014 seconds (Warm-up)
Chain 1: 0.014 seconds (Sampling)
Chain 1: 0.028 seconds (Total)
Chain 1:
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 6e-06 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 0.022 seconds (Warm-up)
Chain 2: 0.017 seconds (Sampling)
Chain 2: 0.039 seconds (Total)
Chain 2:
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 5e-06 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 0.021 seconds (Warm-up)
Chain 3: 0.012 seconds (Sampling)
Chain 3: 0.033 seconds (Total)
Chain 3:
SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 5e-06 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 0.02 seconds (Warm-up)
Chain 4: 0.017 seconds (Sampling)
Chain 4: 0.037 seconds (Total)
Chain 4:
Inference for Stan model: anon_model.
4 chains, each with iter=2000; warmup=1000; thin=1;
post-warmup draws per chain=1000, total post-warmup draws=4000.
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
lambda 1.45 0.02 0.72 0.44 0.93 1.31 1.82 3.24 1796 1
lp__ -3.23 0.02 0.69 -5.22 -3.35 -2.97 -2.81 -2.76 1524 1
Samples were drawn using NUTS(diag_e) at Fri Aug 16 21:29:01 2024.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at
convergence, Rhat=1).
|
So it looks like both parsing and sampling from your Stan model is working without issue. What R code are you running that is giving the error still? |
RStudio 2024.04.2+764 "Chocolate Cosmos" Release (e4392fc9ddc21961fd1d0efd47484b43f07a4177, 2024-06-05) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2024.04.2+764 Chrome/120.0.6099.291 Electron/28.3.1 Safari/537.36, Quarto 1.4.555
…________________________________
From: Andrew Johnson ***@***.***>
Sent: Friday, August 16, 2024 9:33 PM
To: stan-dev/stanc3 ***@***.***>
Cc: tuulam ***@***.***>; Mention ***@***.***>
Subject: Re: [stan-dev/stanc3] Internal compiler error: TypeError: a.charCodeAt is not a function (Issue #1446)
So it looks like both parsing and sampling from your Stan model is working without issue. What R code are you running that is giving the error still?
—
Reply to this email directly, view it on GitHub<#1446 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALZZ4U5PZXJAVTSU6A53VFTZRZAZHAVCNFSM6AAAAABMTUEG2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTHE3TGOJVGU>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
As mentioned in #1475, this appears to be a junk-in-junk-out issue originating in RStan (stan-dev/rstan#1145) which was masked by the fact that stancjs wasn't giving a great error when it was passed an incorrect type |
This happened also a couple of days ago. Now I have the code that caused it:
Rstan 2.35.0.9000
This should never happen. Please file a bug at https://github.com/stan-dev/stanc3/issues/new
and include this message and the model that caused this issue.
I removed the package V8 but it didn't change the situation.
The text was updated successfully, but these errors were encountered: