Skip to content

Commit

Permalink
Rel 7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
goedman committed Feb 6, 2023
1 parent 140a134 commit 96a2ff8
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
matrix:
version:
- '1.8'
- '1.9-beta3'
#- '1.9-beta3'
- 'nightly'
os:
- ubuntu-latest
Expand Down
14 changes: 7 additions & 7 deletions ext/BridgeStanExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ using StanSample, DocStringExtensions

StanSample.EXTENSIONS_SUPPORTED ? (using BridgeStan) : (using ..BridgeStan)

import StanSample: create_smb
#import StanSample: create_smb

const BS = BridgeStan
const BRIDGESTAN_PATH = get_bridgestan_path()
println(BRIDGESTAN_PATH)
BS.set_bridgestan_path!(BRIDGESTAN_PATH)
export BS, BRIDGESTAN_HOME, StanModel

BridgeStan.set_bridgestan_path!(BRIDGESTAN_PATH)
export StanModel

#=
"""
Create a BridgeStan shared object.
Expand All @@ -37,10 +36,10 @@ if either the shared object or data file is missing.
Exported
"""
function StanSample.create_smb(sm::SampleModel,
data_file=joinpath(sm.tmpdir, sm.name*"_data_1.json");
function StanSample.create_smb(sm::SampleModel;
stanc_args=["--warn-pedantic --O1"],
make_args=["CXX=clang++", "STAN_THREADS=true"],
data_file=joinpath(sm.tmpdir, sm.name*"_data_1.json"),
seed = 204,
chain_id = 0
)
Expand All @@ -67,5 +66,6 @@ function StanSample.create_smb(sm::SampleModel,
smb
end
=#

end
14 changes: 0 additions & 14 deletions ext/MonteCarloMeasurementsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,4 @@ function StanSample.convert_a3d(a3d_array, cnames, ::Val{:particles};

end

#=
function StanSample.particles(df::DataFrame)
d = OrderedDict{Symbol, typeof(Particles(size(df, 1), Normal(0.0, 1.0)))}()
for var in Symbol.(names(df))
d[var] = Particles(df[:, var])
end
(;d...)
end
=#

end
6 changes: 2 additions & 4 deletions src/stanmodel/extension_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
# Functions to be flashed out using extensions.

function inferencedata() end
function create_smb() end
function particles() end
#function create_smb() end
function matrix() end
function convert_a3d() end

export
inferencedata,
create_smb,
particles,
#create_smb,
matrix,
convert_a3d
10 changes: 4 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ if haskey(ENV, "CMDSTAN") || haskey(ENV, "JULIA_CMDSTAN_HOME")
include(joinpath(TestDir, "test_bernoulli/test_bernoulli_keyedarray_01.jl"))

if success(rc)

sdf = read_summary(sm, :dataframe)
sdf = read_summary(sm)
sdf |> display

@test sdf[sdf.parameters .== :theta, :mean][1] 0.33 rtol=0.05

(samples, parameters) = read_samples(sm, :array;
return_parameters=true)
(samples, parameters) = read_samples(sm, :array; return_parameters=true)
@test size(samples) == (1000, 1, 6)
@test length(parameters) == 1

Expand Down Expand Up @@ -58,7 +56,7 @@ if haskey(ENV, "CMDSTAN") || haskey(ENV, "JULIA_CMDSTAN_HOME")

end

if Int(VERSION.minor) > 8
#if Int(VERSION.minor) > 8

test_bridgestan = [
"test_bridgestan/test_bridgestan.jl",
Expand All @@ -73,7 +71,7 @@ if haskey(ENV, "CMDSTAN") || haskey(ENV, "JULIA_CMDSTAN_HOME")
println()
end

end
#end

println()
test_inferencedata = [
Expand Down
4 changes: 2 additions & 2 deletions test/test_bernoulli/test_bernoulli_array_01.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######### StanSample Bernoulli example ###########

using StanSample
using AxisKeys, StanSample

bernoulli_model = "
data {
Expand All @@ -24,7 +24,7 @@ rc = stan_sample(sm; data);
if success(rc)
(samples, cnames) = read_samples(sm, :array; return_parameters=true)

ka = read_samples(sm)
ka = read_samples(sm, :keyedarray)
ka |> display
println()

Expand Down
2 changes: 1 addition & 1 deletion test/test_bernoulli/test_bernoulli_keyedarray_01.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
######### StanSample Bernoulli example ###########

using StanSample
using AxisKeys, StanSample

bernoulli_model = "
data {
Expand Down
9 changes: 8 additions & 1 deletion test/test_bridgestan/test_bridgestan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ if success(rc)
post = read_samples(sm, :dataframe)
end

smb = create_smb(sm, joinpath(sm.tmpdir, "$(sm.name)_data_1.json"))
smb = BridgeStan.StanModel(;
stan_file = sm.output_base * ".stan",
stanc_args = ["--warn-pedantic --O1"],
make_args = ["CXX=clang++", "STAN_THREADS=true"],
data=sm.output_base * "_data_1.json",
seed = 204,
chain_id = 0
)

println("This model's name is $(BridgeStan.name(smb)).")
println("It has $(BridgeStan.param_num(smb)) parameters.")
Expand Down

0 comments on commit 96a2ff8

Please sign in to comment.