From 69146e7ae94f18cd9a0103eff51ec21084a2b110 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Fri, 13 Dec 2024 10:41:13 -0500 Subject: [PATCH 1/2] Bump min Julia version to new LTS (1.10) --- .github/workflows/main.yaml | 2 +- docs/languages/julia.md | 40 ++++++++++++++++++------------------- julia/Project.toml | 2 +- julia/docs/src/julia.md | 2 +- julia/src/model.jl | 15 +++----------- 5 files changed, 26 insertions(+), 35 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d4f4b6d3..da962c2a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -151,7 +151,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] julia-version: ["1"] include: - - julia-version: "1.6" + - julia-version: "lts" os: ubuntu-latest fail-fast: false steps: diff --git a/docs/languages/julia.md b/docs/languages/julia.md index c690706c..e46578e3 100644 --- a/docs/languages/julia.md +++ b/docs/languages/julia.md @@ -75,7 +75,7 @@ from the BridgeStan folder. To use the BridgeStan source you've manually downloaded instead of one the package will download for you, you must use [`set_bridgestan_path()`](BridgeStan.set_bridgestan_path!) or the `$BRIDGESTAN` environment variable. -Note that the Julia package depends on Julia 1.6+ and the `Inflate` package. +Note that the Julia package depends on Julia 1.10 (LTS) and the `Inflate` package. @@ -131,7 +131,7 @@ Data should either be a string containing a JSON string literal, a path to a dat If seed is supplied, it is used to initialize the RNG used by the model's constructor. -source
+source
# **`BridgeStan.log_density`** — *Function*. @@ -165,7 +165,7 @@ This calculation drops constant terms that do not depend on the parameters if `p This allocates new memory for the gradient output each call. See [`log_density_gradient!`](julia.md#BridgeStan.log_density_gradient!) for a version which allows re-using existing memory. -source
+source
# **`BridgeStan.log_density_hessian`** — *Function*. @@ -183,7 +183,7 @@ This calculation drops constant terms that do not depend on the parameters if `p This allocates new memory for the gradient and Hessian output each call. See [`log_density_hessian!`](julia.md#BridgeStan.log_density_hessian!) for a version which allows re-using existing memory. -source
+source
# **`BridgeStan.log_density_hessian_vector_product`** — *Function*. @@ -201,7 +201,7 @@ This calculation drops constant terms that do not depend on the parameters if `p This allocates new memory for the output each call. See [`log_density_hessian_vector_product!`](julia.md#BridgeStan.log_density_hessian_vector_product!) for a version which allows re-using existing memory. -source
+source
# **`BridgeStan.param_constrain`** — *Function*. @@ -221,7 +221,7 @@ This allocates new memory for the output each call. See [`param_constrain!`](jul This is the inverse of [`param_unconstrain`](julia.md#BridgeStan.param_unconstrain). -source
+source
# **`BridgeStan.param_unconstrain`** — *Function*. @@ -241,7 +241,7 @@ This allocates new memory for the output each call. See [`param_unconstrain!`](j This is the inverse of [`param_constrain`](julia.md#BridgeStan.param_constrain). -source
+source
# **`BridgeStan.param_unconstrain_json`** — *Function*. @@ -273,7 +273,7 @@ name(sm) Return the name of the model `sm` -source
+source
# **`BridgeStan.model_info`** — *Function*. @@ -289,7 +289,7 @@ Return information about the model `sm`. This includes the Stan version and important compiler flags. -source
+source
# **`BridgeStan.param_num`** — *Function*. @@ -305,7 +305,7 @@ Return the number of (constrained) parameters in the model. This is the total of all the sizes of items declared in the `parameters` block of the model. If `include_tp` or `include_gq` are true, items declared in the `transformed parameters` and `generate quantities` blocks are included, respectively. -source
+source
# **`BridgeStan.param_unc_num`** — *Function*. @@ -321,7 +321,7 @@ Return the number of unconstrained parameters in the model. This function is mainly different from `param_num` when variables are declared with constraints. For example, `simplex[5]` has a constrained size of 5, but an unconstrained size of 4. -source
+source
# **`BridgeStan.param_names`** — *Function*. @@ -339,7 +339,7 @@ For containers, indexes are separated by periods (.). For example, the scalar `a` has indexed name `"a"`, the vector entry `a[1]` has indexed name `"a.1"` and the matrix entry `a[2, 3]` has indexed names `"a.2.3"`. Parameter order of the output is column major and more generally last-index major for containers. -source
+source
# **`BridgeStan.param_unc_names`** — *Function*. @@ -355,7 +355,7 @@ Return the indexed names of the unconstrained parameters. For example, a scalar unconstrained parameter `b` has indexed name `b` and a vector entry `b[3]` has indexed name `b.3`. -source
+source
# **`BridgeStan.log_density_gradient!`** — *Function*. @@ -391,7 +391,7 @@ This calculation drops constant terms that do not depend on the parameters if `p The gradient is stored in the vector `out_grad` and the Hessian is stored in `out_hess` and references are returned. See [`log_density_hessian`](julia.md#BridgeStan.log_density_hessian) for a version which allocates fresh memory. -source
+source
# **`BridgeStan.log_density_hessian_vector_product!`** — *Function*. @@ -409,7 +409,7 @@ This calculation drops constant terms that do not depend on the parameters if `p The product is stored in the vector `out` and a reference is returned. See [`log_density_hessian_vector_product`](julia.md#BridgeStan.log_density_hessian_vector_product) for a version which allocates fresh memory. -source
+source
# **`BridgeStan.param_constrain!`** — *Function*. @@ -429,7 +429,7 @@ The result is stored in the vector `out`, and a reference is returned. See [`par This is the inverse of [`param_unconstrain!`](julia.md#BridgeStan.param_unconstrain!). -source
+source
# **`BridgeStan.param_unconstrain!`** — *Function*. @@ -449,7 +449,7 @@ The result is stored in the vector `out`, and a reference is returned. See [`par This is the inverse of [`param_constrain!`](julia.md#BridgeStan.param_constrain!). -source
+source
# **`BridgeStan.param_unconstrain_json!`** — *Function*. @@ -467,7 +467,7 @@ The JSON is expected to be in the [JSON Format for CmdStan](https://mc-stan.org/ The result is stored in the vector `out`, and a reference is returned. See [`param_unconstrain_json`](julia.md#BridgeStan.param_unconstrain_json) for a version which allocates fresh memory. -source
+source
# **`BridgeStan.StanRNG`** — *Type*. @@ -485,7 +485,7 @@ This can be used in the [`param_constrain`](julia.md#BridgeStan.param_constrain) This object is not thread-safe, one should be created per thread. -source
+source
# **`BridgeStan.new_rng`** — *Function*. @@ -503,7 +503,7 @@ This can be used in the [`param_constrain`](julia.md#BridgeStan.param_constrain) The StanRNG object created is not thread-safe, one should be created per thread. -source
+source
diff --git a/julia/Project.toml b/julia/Project.toml index 456dd37e..f3d4a8f9 100644 --- a/julia/Project.toml +++ b/julia/Project.toml @@ -18,4 +18,4 @@ Downloads = "1" TOML = "1" Inflate = "0.1" Tar = "1" -julia = "1.6" +julia = "1.10" diff --git a/julia/docs/src/julia.md b/julia/docs/src/julia.md index a69ac5a7..6d5c619a 100644 --- a/julia/docs/src/julia.md +++ b/julia/docs/src/julia.md @@ -51,7 +51,7 @@ one the package will download for you, you must use [`set_bridgestan_path()`](BridgeStan.set_bridgestan_path!) or the `$BRIDGESTAN` environment variable. -Note that the Julia package depends on Julia 1.6+ and the `Inflate` package. +Note that the Julia package depends on Julia 1.10 (LTS) and the `Inflate` package. ## Example Program diff --git a/julia/src/model.jl b/julia/src/model.jl index 0fbee5cb..22cfafb6 100644 --- a/julia/src/model.jl +++ b/julia/src/model.jl @@ -4,15 +4,6 @@ struct StanModelStruct end mutable struct StanRNGStruct end -# utility macro to annotate a field as const only if supported -@eval macro $(Symbol("const"))(x) - if VERSION >= v"1.8" - Expr(:const, esc(x)) - else - esc(x) - end -end - """ StanModel(lib, data="", seed=204; stanc_args=[], make_args=[], warn=true) @@ -34,9 +25,9 @@ If seed is supplied, it is used to initialize the RNG used by the model's constr mutable struct StanModel lib::Ptr{Nothing} stanmodel::Ptr{StanModelStruct} - @const data::String - @const seed::UInt32 - @const param_unc_num::Int + const data::String + const seed::UInt32 + const param_unc_num::Int function StanModel( lib::String, From 1bc57d149d08f47edec7a3756a5d38897a3f02a2 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Fri, 13 Dec 2024 13:53:38 -0500 Subject: [PATCH 2/2] Update test --- julia/test/util_tests.jl | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/julia/test/util_tests.jl b/julia/test/util_tests.jl index 0828231b..5987065f 100644 --- a/julia/test/util_tests.jl +++ b/julia/test/util_tests.jl @@ -1,31 +1,6 @@ using BridgeStan -using BridgeStan: @const using Test -mutable struct Foo - x::Any - @const y -end - -@testset "@const utility" begin - a = Foo(1, 2) - @test a.x == 1 - @test a.y == 2 - a.x = 3 - @test a.x == 3 - @test a.y == 2 - if VERSION ≥ v"1.8" - # y is const - @test_throws ErrorException a.y = 4 - else - # y is mutable - a.y = 4 - @test a.y == 4 - end -end - - - @testset "download" begin withenv("BRIDGESTAN" => nothing) do existing = BridgeStan.get_bridgestan_path(download = false)