Skip to content

Commit a95510f

Browse files
nsicchaclaude
andcommitted
Add dirichlet/multi_normal lpxf_expr, fix string interpolation in print
- Add dirichlet_lpdf, multi_normal_lpdf to lpxf_expr list - Add dirichlet_lpdfs to builtin - Replace string interpolation in print calls with separate arguments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent da3db0b commit a95510f

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/StanBlocks.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ unwrap_error(e) = e
4747

4848
function _format_cause(phase, context, cause_error, expr_stack)
4949
sprint() do io
50-
print(io, "StanBlocksError [$(phase)]: $(context)\n")
50+
print(io, "StanBlocksError [", phase, "]: ", context, "\n")
5151
print(io, " Caused by: ")
5252
showerror(io, cause_error)
5353
if !isempty(expr_stack)
5454
println(io, "\n\n While processing:")
5555
for (i, item) in enumerate(reverse(expr_stack))
5656
x, lnn = item isa Tuple ? item : (item, nothing)
57-
loc = lnn isa LineNumberNode ? " at $(lnn.file):$(lnn.line)" : ""
58-
println(io, " [$i] $x$loc")
57+
loc = lnn isa LineNumberNode ? (" at ", lnn.file, ":", lnn.line) : ()
58+
print(io, " [", i, "] ", x, loc..., "\n")
5959
end
6060
end
6161
end
@@ -72,7 +72,7 @@ function Base.showerror(io::IO, e::StanBlocksError, bt; kwargs...)
7272
try
7373
showerror(io, e)
7474
catch internal_err
75-
print(io, "StanBlocksError [$(e.phase)]: $(e.context)")
75+
print(io, "StanBlocksError [", e.phase, "]: ", e.context)
7676
print(io, "\n (internal error in showerror: ")
7777
showerror(io, internal_err)
7878
print(io, ")")

src/slic_stan/builtin.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ import Statistics
333333
normal_lpdfs(args...) = normal_lpdf(args...)
334334
normal_lpdfs(obs::anything[n], loc, scale) = jbroadcasted(normal_lpdfs, obs, loc, scale)
335335
multi_normal_lpdfs(args...) = multi_normal_lpdf(args...)
336+
dirichlet_lpdfs(args...) = dirichlet_lpdf(args...)
336337
# Scalar-fallback _lpdfs for distributions missing vectorized forms.
337338
# The args... variant handles scalar obs; array broadcasting is left for future work.
338339
cauchy_lpdfs(args...) = cauchy_lpdf(args...)

src/slic_stan/slic.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ for lpxf_rhs in (
687687
:beta_lpdf, :lognormal_lpdf, :exponential_lpdf, :gamma_lpdf,
688688
:inv_gamma_lpdf, :weibull_lpdf, :uniform_lpdf,
689689
:double_exponential_lpdf, :logistic_lpdf,
690+
:dirichlet_lpdf, :multi_normal_lpdf,
690691
:bernoulli_lpmf, :bernoulli_logit_lpmf, :binomial_lpmf, :binomial_logit_lpmf,
691692
:neg_binomial_2_lpmf, :poisson_lpmf, :poisson_log_lpmf,
692693
)
@@ -781,7 +782,7 @@ Base.show(io::IO, x::StanModel) = show(StanIO(io), x)
781782
Base.show(io::IO, x::SlicModel; mayfail=true) = try
782783
print(io, stan_model(x))
783784
catch e
784-
mayfail && return print(io, "SlicModel: Something went wrong: $e")
785+
mayfail && return print(io, "SlicModel: Something went wrong:", e)
785786
rethrow(e)
786787
end
787788
Base.show(io::IO, x::StanBlock) = if true#length(content(x)) > 0

0 commit comments

Comments
 (0)