Skip to content

Commit

Permalink
Rel 20.4.2 - Duplicate tmpdir example for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
goedman committed Jul 12, 2023
1 parent ff54dfe commit 22eeeb1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
36 changes: 36 additions & 0 deletions Examples/Bernoulli/bernoulli2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

using StanSample

function duplicate_tmpdir_for_windows_only(sm)

tmp2 = mktempdir()
exefile = Sys.iswindows() ? joinpath(sm.name, ".exe") : sm.name
files = [sm.name * ".stan", sm.name * ".hpp", exefile]
for f in files
cp(joinpath(sm.tmpdir, f), joinpath(tmp2, f))
end

sm2 = deepcopy(sm)
sm2.tmpdir = tmp2
sm2.output_base = joinpath(tmp2, sm2.name)

return sm2
end

ProjDir = @__DIR__

bernoullimodel = "
Expand Down Expand Up @@ -35,3 +51,23 @@ if success(rc)
df = read_summary(sm, true)
df |> display
end

if true # Sys.iswindows()
df1 = read_samples(sm, :dataframe)

sm2 = duplicate_tmpdir_for_windows_only(sm)
rc2 = stan_sample(sm2; data=observed_data,
save_warmup=true, num_warmups=1000,
num_samples=1000, thin=1, delta=0.85)

df2 = read_samples(sm2, :dataframe)

println(DataFrame(df1=df1[1001:1006, 1], df2=df2[1001:1006, 1]))
println()

if success(rc2)
df3 = read_summary(sm, true)
df3 |> display
end

end
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "682df890-35be-576f-97d0-3d8c8b33a550"
license = "MIT"
desc = "Illustrate StanJulia's interface options to cmdstan"
authors = ["Rob J Goedman <[email protected]>"]
version = "10.4.1"
version = "10.4.2"

[deps]
AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,18 @@ Set the CMDSTAN environment variable so that Julia can find the cmdstan installa

## Versions

### Version 10.4.2

1. Mainly package updates.
2. Added an example (function) to duplicate a tmpdir on Windows. See `Examples/Bernoulli/bernoulli2.jl`.

### Version 10.4.0

1. Switch to cmdstan.2.32.0 based testing.

### Version 10.3.3

1. Removed direct testing of BridgeStan (as it was removed from StanSample.jl)
1. Removed direct testing of BridgeStan (as it was removed from StanSample.jl).
2. Two examples of how to use Bridgestan can be found in PlutoExampleNotebooks.jl (`test_bridgestan.jl`and
`bridgestan_stansample_example.jl`) in [above mentioned Github repo](https://github.com/StanJulia/StanExampleNotebooks.jl/tree/main/notebooks/BridgeStan).

Expand Down

0 comments on commit 22eeeb1

Please sign in to comment.