From f77e9c0e881eafbeb4c38789d582eb21b2f62432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20K=2E=20Papp?= Date: Wed, 30 Apr 2025 10:38:14 +0200 Subject: [PATCH 1/3] update CI and bounds, remove SimpleUnpack from dependencies --- .github/workflows/CI.yml | 4 ++-- Project.toml | 2 +- docs/Project.toml | 2 +- docs/src/index.md | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 862f45d..48e98ea 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,8 +17,8 @@ jobs: fail-fast: false matrix: version: - - '1.6' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'. - - '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia. + - 'min' + - '1' # will automatically expand to the latest stable 1.x release of Julia. # - 'nightly' # NOTE: nightly disabled as it currently fails os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 8c46714..3bc0c2a 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] ArgCheck = "1, 2" DocStringExtensions = "0.8, 0.9" -julia = "1.6" +julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/docs/Project.toml b/docs/Project.toml index 2a57321..c3948d3 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -2,8 +2,8 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c" LogDensityProblemsAD = "996a588d-648d-4e1f-a8f0-a84b347e47b1" -SimpleUnPack = "ce78b400-467f-4804-87d8-8f486da07d0a" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" TransformVariables = "84d833dd-6860-57f9-a1a7-6da5db126cff" TransformedLogDensities = "f9bc47f6-f3f8-4f3b-ab21-f8bc73906f26" diff --git a/docs/src/index.md b/docs/src/index.md index 95ab3c9..0d29698 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -48,7 +48,7 @@ It is useful to define a *callable* that implements this, taking some vector `x` ```@example 1 using Random; Random.seed!(1) # hide -using Statistics, SimpleUnPack # imported for our implementation +using Statistics struct NormalPosterior{T} # contains the summary statistics N::Int @@ -63,8 +63,8 @@ end # define a callable that unpacks parameters, and evaluates the log likelihood function (problem::NormalPosterior)(θ) - @unpack μ, σ = θ - @unpack N, x̄, S = problem + (; μ, σ) = θ + (; N, x̄, S) = problem loglikelihood = -N * (log(σ) + (S + abs2(μ - x̄)) / (2 * abs2(σ))) logprior = - abs2(σ)/8 - abs2(μ)/50 loglikelihood + logprior From 099167f285d76e8f336451f1dd82ad056e1f21ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20K=2E=20Papp?= Date: Wed, 30 Apr 2025 10:50:34 +0200 Subject: [PATCH 2/3] dust off docs --- docs/src/index.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/src/index.md b/docs/src/index.md index 0d29698..ed4e65c 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -46,7 +46,11 @@ which is added to the log likelihood to obtain the log posterior. It is useful to define a *callable* that implements this, taking some vector `x` as an input and calculating the summary statistics, then, when called with a `NamedTuple` containing the parameters, evaluating to the log posterior. -```@example 1 +```@setup A +using LogDensityProblems +``` + +```@example A using Random; Random.seed!(1) # hide using Statistics @@ -76,7 +80,7 @@ nothing # hide Let's try out the posterior calculation: -```@repl 1 +```@repl A problem((μ = 0.0, σ = 1.0)) ``` @@ -90,13 +94,13 @@ In our example, we require ``\sigma > 0``, otherwise the problem is meaningless. !!! note Since version 1.0, TransformedLogDensity has been moved to the package TransformedLogDensities. -```@repl 1 +```@repl A using LogDensityProblems, TransformVariables, TransformedLogDensities ℓ = TransformedLogDensity(as((μ = asℝ, σ = asℝ₊)), problem) ``` Then we can query the dimension of this problem, and evaluate the log density: -```@repl 1 +```@repl A LogDensityProblems.dimension(ℓ) LogDensityProblems.logdensity(ℓ, zeros(2)) ``` @@ -108,7 +112,7 @@ LogDensityProblems.logdensity(ℓ, zeros(2)) If you prefer to implement the transformation yourself, you just have to define the following three methods for your problem: declare that it can evaluate log densities (but not their gradient, hence the `0` order), allow the dimension of the problem to be queried, and then finally code the density calculation with the transformation. (Note that using `TransformedLogDensities.TransformedLogDensity` takes care of all of these for you, as shown above). -```@example 1 +```@example A function LogDensityProblems.capabilities(::Type{<:NormalPosterior}) LogDensityProblems.LogDensityOrder{0}() end @@ -123,7 +127,7 @@ end nothing # hide ``` -```@repl 1 +```@repl A LogDensityProblems.logdensity(problem, zeros(2)) ``` @@ -134,7 +138,7 @@ Here we use the exponential function to transform from ``\mathbb{R}`` to the pos Using either definition, you can transform to another object which is capable of evaluating the *gradient*, using automatic differentiation. For this, you need the [LogDensityProblemsAD.jl](https://github.com/tpapp/LogDensityProblemsAD.jl) package. Now observe that we can obtain gradients, too: -```@repl 1 +```@repl A import ForwardDiff using LogDensityProblemsAD ∇ℓ = ADgradient(:ForwardDiff, ℓ) From 023ddb8cb9eda96c90b94778f913b1a10355b50a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20K=2E=20Papp?= Date: Wed, 30 Apr 2025 10:53:29 +0200 Subject: [PATCH 3/3] dust off CI actions --- .github/workflows/CI.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 48e98ea..b2b5c7d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -30,7 +30,7 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: @@ -43,7 +43,9 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v5 with: + file: lcov.info + # NOTE: you need to add the token to Github secrets, see + # https://docs.codecov.com/docs/adding-the-codecov-token token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: false # or true if you want CI to fail when Codecov fails