From 8f20476904fa5533644fc388984ba620e96270a8 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Tue, 23 Jun 2026 22:59:09 +0100 Subject: [PATCH 01/10] Emit a downloadable Jupyter notebook for each docs example Each example is already a Literate.jl script rendered to markdown for Documenter. Also call Literate.notebook to emit a runnable .ipynb into the docs source tree; Documenter copies it verbatim into the build output, so it is deployed to gh-pages alongside the HTML (e.g. .../examples/.ipynb). Applies to GeneralisedFilters (trend-inflation) and SSMProblems (kalman-filter). Verified both scripts produce valid Julia notebooks. Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/literate.jl | 2 ++ SSMProblems/docs/literate.jl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index feb1e47b..ab67ba16 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -17,3 +17,5 @@ using Literate: Literate # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true) +# Also emit a runnable notebook; Documenter copies it into the deployed site. +Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 879ec107..759e7e66 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -16,3 +16,5 @@ using Literate: Literate # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true) +# Also emit a runnable notebook; Documenter copies it into the deployed site. +Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) From 7fef5a6a443c97298d7f1e85045e68ca418fcd96 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Tue, 23 Jun 2026 23:04:59 +0100 Subject: [PATCH 02/10] Add an Open in Colab badge to each docs example A Literate preprocess inserts an "Open in Colab" badge after the title (in both the rendered page and the notebook) pointing at the notebook deployed to gh-pages. The link targets the stable `dev` build; the notebook is also deployed under previews/PR/ and release dirs, which the fixed dev link does not resolve to. Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/literate.jl | 30 +++++++++++++++++++++++++++-- SSMProblems/docs/literate.jl | 30 +++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index ab67ba16..24b3bb71 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -14,8 +14,34 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate +# Insert an "Open in Colab" badge (after the title) that opens the notebook published to +# the gh-pages docs. The link targets the `dev` build for a stable URL; note the same +# notebook is also deployed under `previews/PR/` (PR previews) and `vX.Y`/`stable` +# (releases), which this fixed `dev` link does not resolve to. +const REPO = "TuringLang/SSMProblems.jl" +const PKG = basename(dirname(@__DIR__)) +const COLAB_BADGE = string( + "# [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)]", + "(https://colab.research.google.com/github/", + REPO, + "/blob/gh-pages/", + PKG, + "/dev/examples/", + EXAMPLE, + ".ipynb)", +) + +function add_colab_badge(content) + lines = string.(split(content, '\n')) + idx = findfirst(line -> startswith(line, "# # "), lines) + idx === nothing && return string(COLAB_BADGE, "\n#\n", content) + insert!(lines, idx + 1, "#") + insert!(lines, idx + 2, COLAB_BADGE) + return join(lines, '\n') +end + # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") -Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true) +Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) # Also emit a runnable notebook; Documenter copies it into the deployed site. -Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) +Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false, preprocess=add_colab_badge) diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 759e7e66..83c68f34 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -13,8 +13,34 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate +# Insert an "Open in Colab" badge (after the title) that opens the notebook published to +# the gh-pages docs. The link targets the `dev` build for a stable URL; note the same +# notebook is also deployed under `previews/PR/` (PR previews) and `vX.Y`/`stable` +# (releases), which this fixed `dev` link does not resolve to. +const REPO = "TuringLang/SSMProblems.jl" +const PKG = basename(dirname(@__DIR__)) +const COLAB_BADGE = string( + "# [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)]", + "(https://colab.research.google.com/github/", + REPO, + "/blob/gh-pages/", + PKG, + "/dev/examples/", + EXAMPLE, + ".ipynb)", +) + +function add_colab_badge(content) + lines = string.(split(content, '\n')) + idx = findfirst(line -> startswith(line, "# # "), lines) + idx === nothing && return string(COLAB_BADGE, "\n#\n", content) + insert!(lines, idx + 1, "#") + insert!(lines, idx + 2, COLAB_BADGE) + return join(lines, '\n') +end + # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") -Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true) +Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) # Also emit a runnable notebook; Documenter copies it into the deployed site. -Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) +Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false, preprocess=add_colab_badge) From d1d49999fcb7a6f0fb123902f8da2c7b75f0df74 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Tue, 23 Jun 2026 23:05:45 +0100 Subject: [PATCH 03/10] Only add the Colab badge to the rendered page, not the notebook Apply the badge-inserting preprocess to Literate.markdown only; the generated notebook no longer carries the Open in Colab badge. Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/literate.jl | 5 +++-- SSMProblems/docs/literate.jl | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 24b3bb71..62c75589 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -43,5 +43,6 @@ end # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) -# Also emit a runnable notebook; Documenter copies it into the deployed site. -Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false, preprocess=add_colab_badge) +# Also emit a runnable notebook; Documenter copies it into the deployed site. The badge is +# only added to the rendered page, not the notebook itself. +Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 83c68f34..45829d3e 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -42,5 +42,6 @@ end # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) -# Also emit a runnable notebook; Documenter copies it into the deployed site. -Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false, preprocess=add_colab_badge) +# Also emit a runnable notebook; Documenter copies it into the deployed site. The badge is +# only added to the rendered page, not the notebook itself. +Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) From 4bf21996111258553208e9ce729d5cbbc51faf2f Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Tue, 23 Jun 2026 23:07:12 +0100 Subject: [PATCH 04/10] Note the notebook deploys under the versioned docs dir Clarify in the comment that the generated notebook is copied under the versioned docs directory (dev/, vX.Y/, or previews/PR/ for PR previews). Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/literate.jl | 5 +++-- SSMProblems/docs/literate.jl | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 62c75589..1734bf92 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -43,6 +43,7 @@ end # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) -# Also emit a runnable notebook; Documenter copies it into the deployed site. The badge is -# only added to the rendered page, not the notebook itself. +# Also emit a runnable notebook; Documenter copies it into the deployed site, under the +# versioned docs dir (dev/, vX.Y/, or previews/PR/ for PR previews). The badge is only +# added to the rendered page, not the notebook itself. Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 45829d3e..87ad5e9e 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -42,6 +42,7 @@ end # Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) -# Also emit a runnable notebook; Documenter copies it into the deployed site. The badge is -# only added to the rendered page, not the notebook itself. +# Also emit a runnable notebook; Documenter copies it into the deployed site, under the +# versioned docs dir (dev/, vX.Y/, or previews/PR/ for PR previews). The badge is only +# added to the rendered page, not the notebook itself. Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) From 7de46736d84c2619fd9dd3f67a7d7b44b301415e Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Tue, 23 Jun 2026 23:09:44 +0100 Subject: [PATCH 05/10] CI: use native runner arch instead of forcing x64 macos-latest is now Apple Silicon (arm64), so the matrix's `arch: x64` failed at the Setup Julia step. Drop the arch axis and let setup-julia use each runner's native arch (x64 on ubuntu/windows, aarch64 on macOS). Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/CI.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bda43dc8..83fc4aba 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ concurrency: jobs: test: - name: ${{ matrix.pkg.name }} - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + name: ${{ matrix.pkg.name }} - Julia ${{ matrix.version }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -25,8 +25,6 @@ jobs: - ubuntu-latest - windows-latest - macOS-latest - arch: - - x64 pkg: - name: SSMProblems dir: './SSMProblems' @@ -40,7 +38,6 @@ jobs: uses: julia-actions/setup-julia@v3 with: version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - name: Cache artifacts uses: julia-actions/cache@v3 From 902164c69e1dac6a7c71ab80dad5b2b274b8327d Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Tue, 23 Jun 2026 23:20:14 +0100 Subject: [PATCH 06/10] Point the Colab badge at the actual deploy version Compute the gh-pages version subdir from the CI context to match Documenter's deploy target: previews/PR for PR previews, the tag (e.g. v1.2.3) for tagged releases, otherwise dev. Previously the badge always linked to dev, so preview/release notebooks were unreachable. Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/literate.jl | 21 +++++++++++++++++---- SSMProblems/docs/literate.jl | 21 +++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 1734bf92..03e0f29c 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -15,18 +15,31 @@ Pkg.instantiate() using Literate: Literate # Insert an "Open in Colab" badge (after the title) that opens the notebook published to -# the gh-pages docs. The link targets the `dev` build for a stable URL; note the same -# notebook is also deployed under `previews/PR/` (PR previews) and `vX.Y`/`stable` -# (releases), which this fixed `dev` link does not resolve to. +# the gh-pages docs. The version subdir matches Documenter's deploy target: `previews/PR` +# for pull-request previews, the tag (e.g. `v1.2.3`) for tagged releases, otherwise `dev`. const REPO = "TuringLang/SSMProblems.jl" const PKG = basename(dirname(@__DIR__)) + +function docs_subfolder() + ref = get(ENV, "GITHUB_REF", "") + if get(ENV, "GITHUB_EVENT_NAME", "") == "pull_request" + pr = match(r"^refs/pull/(\d+)/", ref) + pr === nothing || return string("previews/PR", only(pr.captures)) + end + tag = match(r"^refs/tags/(.+)$", ref) + tag === nothing || return only(tag.captures) + return "dev" +end + const COLAB_BADGE = string( "# [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)]", "(https://colab.research.google.com/github/", REPO, "/blob/gh-pages/", PKG, - "/dev/examples/", + "/", + docs_subfolder(), + "/examples/", EXAMPLE, ".ipynb)", ) diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 87ad5e9e..f146fac7 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -14,18 +14,31 @@ Pkg.instantiate() using Literate: Literate # Insert an "Open in Colab" badge (after the title) that opens the notebook published to -# the gh-pages docs. The link targets the `dev` build for a stable URL; note the same -# notebook is also deployed under `previews/PR/` (PR previews) and `vX.Y`/`stable` -# (releases), which this fixed `dev` link does not resolve to. +# the gh-pages docs. The version subdir matches Documenter's deploy target: `previews/PR` +# for pull-request previews, the tag (e.g. `v1.2.3`) for tagged releases, otherwise `dev`. const REPO = "TuringLang/SSMProblems.jl" const PKG = basename(dirname(@__DIR__)) + +function docs_subfolder() + ref = get(ENV, "GITHUB_REF", "") + if get(ENV, "GITHUB_EVENT_NAME", "") == "pull_request" + pr = match(r"^refs/pull/(\d+)/", ref) + pr === nothing || return string("previews/PR", only(pr.captures)) + end + tag = match(r"^refs/tags/(.+)$", ref) + tag === nothing || return only(tag.captures) + return "dev" +end + const COLAB_BADGE = string( "# [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)]", "(https://colab.research.google.com/github/", REPO, "/blob/gh-pages/", PKG, - "/dev/examples/", + "/", + docs_subfolder(), + "/examples/", EXAMPLE, ".ipynb)", ) From cd4ddd21b8f3df5793b115bf54412beed1898c22 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Tue, 23 Jun 2026 23:32:55 +0100 Subject: [PATCH 07/10] Make generated notebooks runnable on Colab In the notebook postprocess: set a generic Julia kernelspec (no pinned version) so Colab uses its default Julia runtime, and prepend a single Pkg.add of all packages the example imports/uses so it installs deps on a fresh Colab runtime. The setup cell is added to the notebook only, not the rendered docs page. Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/literate.jl | 50 ++++++++++++++++++++++++++--- SSMProblems/docs/literate.jl | 50 ++++++++++++++++++++++++++--- 2 files changed, 92 insertions(+), 8 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 03e0f29c..3a9ecfb7 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -53,10 +53,52 @@ function add_colab_badge(content) return join(lines, '\n') end -# Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") + +# Top-level `using`/`import` package names, so the notebook can install them on Colab. +function script_packages(path) + pkgs = String[] + for line in eachline(path) + m = match(r"^\s*(?:using|import)\s+(.+)", line) + m === nothing && continue + for part in split(first(split(m.captures[1], ':')), ',') + token = first(split(strip(part), r"\s+as\s+")) + name = strip(first(split(token, '.'))) + isempty(name) || name in pkgs || push!(pkgs, String(name)) + end + end + return sort(pkgs) +end + +# Notebook postprocess: use a generic Julia kernel (so Colab picks its default Julia +# runtime, with no pinned version) and prepend a single Pkg.add for all imported packages +# so the notebook runs on a fresh Colab runtime. +function prepare_notebook(nb) + nb["metadata"]["kernelspec"] = Dict( + "display_name" => "Julia", "language" => "julia", "name" => "julia" + ) + delete!(nb["metadata"], "language_info") + packages = script_packages(SCRIPTJL) + if !isempty(packages) + setup = Dict( + "cell_type" => "code", + "execution_count" => nothing, + "metadata" => Dict(), + "outputs" => [], + "source" => + ["import Pkg\n", string("Pkg.add([", join(repr.(packages), ", "), "])")], + ) + idx = findfirst(cell -> cell["cell_type"] == "code", nb["cells"]) + insert!(nb["cells"], something(idx, lastindex(nb["cells"]) + 1), setup) + end + return nb +end + +# Convert to markdown and notebook Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) # Also emit a runnable notebook; Documenter copies it into the deployed site, under the -# versioned docs dir (dev/, vX.Y/, or previews/PR/ for PR previews). The badge is only -# added to the rendered page, not the notebook itself. -Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) +# versioned docs dir (dev/, vX.Y/, or previews/PR/ for PR previews). The badge goes on +# the rendered page only; the notebook gets a Colab setup cell instead. +Literate.notebook( + SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false, postprocess=prepare_notebook +) diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index f146fac7..73b2a3ea 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -52,10 +52,52 @@ function add_colab_badge(content) return join(lines, '\n') end -# Convert to markdown and notebook const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") + +# Top-level `using`/`import` package names, so the notebook can install them on Colab. +function script_packages(path) + pkgs = String[] + for line in eachline(path) + m = match(r"^\s*(?:using|import)\s+(.+)", line) + m === nothing && continue + for part in split(first(split(m.captures[1], ':')), ',') + token = first(split(strip(part), r"\s+as\s+")) + name = strip(first(split(token, '.'))) + isempty(name) || name in pkgs || push!(pkgs, String(name)) + end + end + return sort(pkgs) +end + +# Notebook postprocess: use a generic Julia kernel (so Colab picks its default Julia +# runtime, with no pinned version) and prepend a single Pkg.add for all imported packages +# so the notebook runs on a fresh Colab runtime. +function prepare_notebook(nb) + nb["metadata"]["kernelspec"] = Dict( + "display_name" => "Julia", "language" => "julia", "name" => "julia" + ) + delete!(nb["metadata"], "language_info") + packages = script_packages(SCRIPTJL) + if !isempty(packages) + setup = Dict( + "cell_type" => "code", + "execution_count" => nothing, + "metadata" => Dict(), + "outputs" => [], + "source" => + ["import Pkg\n", string("Pkg.add([", join(repr.(packages), ", "), "])")], + ) + idx = findfirst(cell -> cell["cell_type"] == "code", nb["cells"]) + insert!(nb["cells"], something(idx, lastindex(nb["cells"]) + 1), setup) + end + return nb +end + +# Convert to markdown and notebook Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true, preprocess=add_colab_badge) # Also emit a runnable notebook; Documenter copies it into the deployed site, under the -# versioned docs dir (dev/, vX.Y/, or previews/PR/ for PR previews). The badge is only -# added to the rendered page, not the notebook itself. -Literate.notebook(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false) +# versioned docs dir (dev/, vX.Y/, or previews/PR/ for PR previews). The badge goes on +# the rendered page only; the notebook gets a Colab setup cell instead. +Literate.notebook( + SCRIPTJL, OUTDIR; name=EXAMPLE, execute=false, postprocess=prepare_notebook +) From c60a8208b88db7509efaa8a20132b409c455ed68 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Wed, 24 Jun 2026 00:00:55 +0100 Subject: [PATCH 08/10] Fix trend-inflation example for the current get_ancestry API get_ancestry now returns ReferenceTrajectory values rather than Vector{Vector{RBState}}, so mean_path's typed method no longer dispatched and the example errored during the docs build (pre-existing on main). Collect each trajectory before extracting state components; verified previously to match the prior plots byte-for-byte. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../examples/trend-inflation/utilities.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/GeneralisedFilters/examples/trend-inflation/utilities.jl b/GeneralisedFilters/examples/trend-inflation/utilities.jl index e3f9e0da..c3a731de 100644 --- a/GeneralisedFilters/examples/trend-inflation/utilities.jl +++ b/GeneralisedFilters/examples/trend-inflation/utilities.jl @@ -17,10 +17,12 @@ end # for normal collections mean_path(paths, states) = _mean_path(identity, paths, states) -# for rao blackwellised particles -function mean_path(paths::Vector{Vector{T}}, states) where {T<:GeneralisedFilters.RBState} - zs = _mean_path(s -> getproperty.(getproperty.(s, :z), :μ), paths, states) - xs = _mean_path(s -> getproperty.(s, :x), paths, states) +# for rao blackwellised particles; `get_ancestry` returns `ReferenceTrajectory`s, which we +# collect into plain vectors before extracting per-time-step state components +function mean_path(paths::AbstractVector{<:GeneralisedFilters.ReferenceTrajectory}, states) + trajectories = map(collect, paths) + zs = _mean_path(s -> getproperty.(getproperty.(s, :z), :μ), trajectories, states) + xs = _mean_path(s -> getproperty.(s, :x), trajectories, states) return zs, xs end From ba0b2a14aad9cfae285f45043975674963b48f71 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Wed, 24 Jun 2026 00:05:17 +0100 Subject: [PATCH 09/10] Only build example dirs that ship a Literate script.jl make.jl iterated every directory under examples/, so the script-only "PGAS Example" dir (no script.jl, no Literate dep) failed the docs build with "Package Literate not found". Filter discovery to dirs containing script.jl. Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/make.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GeneralisedFilters/docs/make.jl b/GeneralisedFilters/docs/make.jl index 117d6cff..72597a59 100644 --- a/GeneralisedFilters/docs/make.jl +++ b/GeneralisedFilters/docs/make.jl @@ -11,7 +11,11 @@ mkpath(EXAMPLES_OUT) # Install and precompile all packages # Workaround for https://github.com/JuliaLang/Pkg.jl/issues/2219 -examples = filter!(isdir, readdir(joinpath(@__DIR__, "..", "examples"); join=true)) +# Only build directories that ship a Literate `script.jl`; other example dirs +# (e.g. script-only scratch examples) are skipped rather than failing the build. +examples = filter(readdir(joinpath(@__DIR__, "..", "examples"); join=true)) do path + return isdir(path) && isfile(joinpath(path, "script.jl")) +end above = joinpath(@__DIR__, "..") ssmproblems_path = joinpath(above, "..", "SSMProblems") let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=\"$(above)\"); Pkg.develop(path=\"$(ssmproblems_path)\"); Pkg.instantiate()" From d87b5725b1b276dc9145321ad1cd6ae1d654c5e5 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Wed, 24 Jun 2026 00:25:27 +0100 Subject: [PATCH 10/10] Drop redundant language_info deletion from notebook postprocess Colab selects the runtime from kernelspec.name (now "julia"), so deleting language_info isn't needed for the generic-Julia/no-version behavior. Co-Authored-By: Claude Opus 4.8 (1M context) --- GeneralisedFilters/docs/literate.jl | 1 - SSMProblems/docs/literate.jl | 1 - 2 files changed, 2 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 3a9ecfb7..1fd8c921 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -77,7 +77,6 @@ function prepare_notebook(nb) nb["metadata"]["kernelspec"] = Dict( "display_name" => "Julia", "language" => "julia", "name" => "julia" ) - delete!(nb["metadata"], "language_info") packages = script_packages(SCRIPTJL) if !isempty(packages) setup = Dict( diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 73b2a3ea..f985ba18 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -76,7 +76,6 @@ function prepare_notebook(nb) nb["metadata"]["kernelspec"] = Dict( "display_name" => "Julia", "language" => "julia", "name" => "julia" ) - delete!(nb["metadata"], "language_info") packages = script_packages(SCRIPTJL) if !isempty(packages) setup = Dict(