Skip to content

Commit 9c378b9

Browse files
nsicchaclaude
andcommitted
Move LogDensityProblems + Markdown from weakdeps to direct deps
Fixes precompilation cycle: StanLogDensityProblems (direct dep) pulls in LogDensityProblems, which triggered the LogDensityProblemsExt extension, creating a circular dependency. Same issue with Markdown. Fold both extensions into the main package and remove ext/ files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1929759 commit 9c378b9

4 files changed

Lines changed: 23 additions & 38 deletions

File tree

Project.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ version = "0.1.5"
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
88
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
99
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10+
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
1011
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
12+
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1113
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1214
StanLogDensityProblems = "a545de4d-8dba-46db-9d34-4e41d3f07807"
1315
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1416

1517
[weakdeps]
1618
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
17-
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
18-
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1919
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
2020
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
2121
PosteriorDB = "1c4bc282-d2f5-44f9-b6d1-8c4424a23ad4"
2222

2323
[extensions]
2424
DifferentiationInterfaceExt = "DifferentiationInterface"
25-
LogDensityProblemsExt = "LogDensityProblems"
26-
MarkdownExt = "Markdown"
2725
MooncakeExt = "Mooncake"
2826
OrdinaryDiffEqExt = "OrdinaryDiffEq"
2927
PosteriorDBExt = "PosteriorDB"

ext/LogDensityProblemsExt.jl

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/StanBlocks.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export @slic, @defsig, @deffun
55
export stan_code, stan_model, stan_instantiate
66
export StanBlocksError
77

8-
using LinearAlgebra, Statistics, Distributions, LogExpFunctions, JSON, StanLogDensityProblems
8+
using LinearAlgebra, Statistics, Distributions, LogExpFunctions, JSON, StanLogDensityProblems, LogDensityProblems, Markdown
99

1010
# --- Error type for StanBlocks computations (defined early so submodules can use it) ---
1111

@@ -35,6 +35,19 @@ slic_implementation(key; kwargs...) = nothing
3535
stan_implementation(key; kwargs...) = missing
3636
include("check.jl")
3737

38+
# --- LogDensityProblems interface ---
39+
LogDensityProblems.capabilities(::Type{VectorPosterior{F,G,GQ,N}}) where{F,G,GQ,N} = if G == Missing
40+
LogDensityProblems.LogDensityOrder{0}()
41+
else
42+
LogDensityProblems.LogDensityOrder{1}()
43+
end
44+
LogDensityProblems.dimension(p::VectorPosterior) = dimension(p)
45+
LogDensityProblems.logdensity(p::VectorPosterior, x) = p(x)
46+
LogDensityProblems.logdensity_and_gradient(p::VectorPosterior, x) = p.g(x)
47+
48+
# --- Markdown/Quarto display ---
49+
include("quarto.jl")
50+
3851
# --- Error display for StanBlocks computations ---
3952

4053
_cause_error(e::StanBlocksError) = e.cause isa Tuple ? e.cause[1] : e.cause
Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
module MarkdownExt
2-
import Markdown, StanBlocks
3-
import StanBlocks: quarto
4-
5-
module Quarto
1+
module Quarto
62
using Markdown
73
abstract type Object end
84
struct Container <: Object
95
children
106
end
11-
struct Heading <: Object
7+
struct Heading <: Object
128
level
139
obj
1410
end
1511
struct Div <: Object
1612
header
1713
content
1814
end
19-
struct Code <: Object
15+
struct Code <: Object
2016
header
2117
content
2218
end
@@ -44,7 +40,7 @@ module Quarto
4440
print(io, child, "\n")
4541
end
4642
Base.show(io::IO, x::Heading) = print(io, repeat("#", x.level), " ", x.obj, "\n")
47-
Base.show(io::IO, x::Div) = begin
43+
Base.show(io::IO, x::Div) = begin
4844
print(io, "\n::: ", x.header, "\n\n")
4945
print(io, x.content)
5046
print(io, "\n:::\n")
@@ -61,20 +57,9 @@ module Quarto
6157
end
6258
end
6359

64-
mapkv(f, x) = map(f, keys(x), values(x))
65-
msg(e) = try
66-
string(e)
67-
catch
68-
"Something went wrong!"
69-
end
70-
msg(e::ErrorException) = msg(e.msg)
71-
72-
Base.show(io::IO, m::MIME"text/markdown", x::StanBlocks.stan.SlicModel) = show(io, m, quarto(x))
60+
Base.show(io::IO, m::MIME"text/markdown", x::stan.SlicModel) = show(io, m, quarto(x))
7361

74-
quarto(x::StanBlocks.stan.SlicModel) = Quarto.Container([
62+
quarto(x::stan.SlicModel) = Quarto.Container([
7563
Quarto.Heading(5, "SlicModel"),
76-
Quarto.Tabset((;stan=Quarto.Code("stan", StanBlocks.stan_code(x)), julia=Quarto.Code("julia", x.model)))
64+
Quarto.Tabset((;stan=Quarto.Code("stan", stan_code(x)), julia=Quarto.Code("julia", x.model)))
7765
])
78-
79-
80-
end

0 commit comments

Comments
 (0)