cscherrer / Soss.jl

Probabilistic programming via source rewriting
https://cscherrer.github.io/Soss.jl/stable/
MIT License
414 stars 30 forks source link

sample(...) does not work #293

Closed FalkoSp closed 2 years ago

FalkoSp commented 3 years ago

Hi, I'm slowly following the JuliaCon21 video. The call to sample(..) fails.

(I had another issue before that it wasn't found in a Pluto notebook. I'll try to reproduce that when I have it running without Pluto.)

using Soss#: @model
using MeasureTheory#: Normal, HalfNormal, Chain
using Base.Iterators#: take
using Pkg: status
using UnicodePlots: lineplot, lineplot!
using SampleChainsDynamicHMC#: dynamichmc

mc_init4 = @model begin
    x ~ Normal(0.0, 1.0)
    return (x=x,)
end

mc_step4 = @model p, s begin
    x ~ Normal(s.x + p.Δμ, p.σ)
    return (x = x,)
end

m4 = @model begin
    Δμ ~ Normal()
    σ ~ HalfNormal()
    p = (; Δμ, σ)
    mc4 ~ Chain(mc_init4()) do s mc_step4(p=p, s=s) end
    return mc4
end

gen4(n) = map(state -> state.x, collect(take(rand(m4()), n)))

p = lineplot(collect(1:100), gen4(100), 
             width=80, height=35,
             ylim=[-50, 50]);
for i in 1:4
    global p = lineplot!(p, gen4(100))
end

display(p)

some_data = collect(take(rand(m4()), 500));
post = m4() | (mc4 = some_data,)

sample(post, dynamichmc())

The call to sample in the last line gives

julia> sample(post, dynamichmc())
ERROR: UndefVarError: StructArrays not defined
Stacktrace:
 [1] chainvec(x::DynamicHMC.TreeStatisticsNUTS, n::Int64)
   @ TupleVectors ~/.julia/packages/TupleVectors/MWcjG/src/chainvec.jl:28
 [2] chainvec
   @ ~/.julia/packages/TupleVectors/MWcjG/src/chainvec.jl:27 [inlined]
 [3] SampleChainsDynamicHMC.DynamicHMCChain(t::TransformVariables.TransformTuple{NamedTuple{(:σ, :Δμ), Tuple{TransformVariables.ShiftedExp{true, Float64}, TransformVariables.Identity}}}, Q::DynamicHMC.EvaluatedLogDensity{Vector{Float64}, Float64}, tree_stats::DynamicHMC.TreeStatisticsNUTS, steps::DynamicHMC.MCMCSteps{Random._GLOBAL_RNG, DynamicHMC.NUTS{Val{:generalized}}, DynamicHMC.Hamiltonian{GaussianKineticEnergy{LinearAlgebra.Diagonal{Float64, Vector{Float64}}, LinearAlgebra.Diagonal{Float64, Vector{Float64}}}, LogDensityProblems.ForwardDiffLogDensity{LogDensityProblems.TransformedLogDensity{TransformVariables.TransformTuple{NamedTuple{(:σ, :Δμ), Tuple{TransformVariables.ShiftedExp{true, Float64}, TransformVariables.Identity}}}, Soss.var"#ℓ#190"{Soss.ConditionalModel{NamedTuple{(), T} where T<:Tuple, GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}, NamedTuple{(), Tuple{}}, NamedTuple{(:mc4,), Tuple{Vector{Any}}}}}}, ForwardDiff.GradientConfig{ForwardDiff.Tag{LogDensityProblems.var"#34#35"{LogDensityProblems.TransformedLogDensity{TransformVariables.TransformTuple{NamedTuple{(:σ, :Δμ), Tuple{TransformVariables.ShiftedExp{true, Float64}, TransformVariables.Identity}}}, Soss.var"#ℓ#190"{Soss.ConditionalModel{NamedTuple{(), T} where T<:Tuple, GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}, NamedTuple{(), Tuple{}}, NamedTuple{(:mc4,), Tuple{Vector{Any}}}}}}}, Float64}, Float64, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{LogDensityProblems.var"#34#35"{LogDensityProblems.TransformedLogDensity{TransformVariables.TransformTuple{NamedTuple{(:σ, :Δμ), Tuple{TransformVariables.ShiftedExp{true, Float64}, TransformVariables.Identity}}}, Soss.var"#ℓ#190"{Soss.ConditionalModel{NamedTuple{(), T} where T<:Tuple, GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}, NamedTuple{(), Tuple{}}, NamedTuple{(:mc4,), Tuple{Vector{Any}}}}}}}, Float64}, Float64, 2}}}}}, Float64})
   @ SampleChainsDynamicHMC ~/.julia/packages/SampleChainsDynamicHMC/Vi6Ia/src/SampleChainsDynamicHMC.jl:34
 [4] newchain(rng::Random._GLOBAL_RNG, config::SampleChainsDynamicHMC.DynamicHMCConfig{Tuple{}, Tuple{InitialStepsizeSearch, TuningNUTS{Nothing, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{Nothing, DualAveraging{Float64}}}, DynamicHMC.NUTS{Val{:generalized}}, NoProgressReport, Val{:ForwardDiff}}, ℓ::Function, tr::TransformVariables.TransformTuple{NamedTuple{(:σ, :Δμ), Tuple{TransformVariables.ShiftedExp{true, Float64}, TransformVariables.Identity}}})
   @ SampleChainsDynamicHMC ~/.julia/packages/SampleChainsDynamicHMC/Vi6Ia/src/SampleChainsDynamicHMC.jl:146
 [5] newchain(::Random._GLOBAL_RNG, ::Int64, ::SampleChainsDynamicHMC.DynamicHMCConfig{Tuple{}, Tuple{InitialStepsizeSearch, TuningNUTS{Nothing, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{Nothing, DualAveraging{Float64}}}, DynamicHMC.NUTS{Val{:generalized}}, NoProgressReport, Val{:ForwardDiff}}, ::Function, ::TransformVariables.TransformTuple{NamedTuple{(:σ, :Δμ), Tuple{TransformVariables.ShiftedExp{true, Float64}, TransformVariables.Identity}}})
   @ SampleChains ~/.julia/packages/SampleChains/fS5ze/src/multichain.jl:36
 [6] sample(rng::Random._GLOBAL_RNG, m::Soss.ConditionalModel{NamedTuple{(), T} where T<:Tuple, GeneralizedGenerated.NGG.TypeLevel{Expr, "Buf{23}()"}, GeneralizedGenerated.NGG.TypeLevel{Module, "Buf{17}()"}, NamedTuple{(), Tuple{}}, NamedTuple{(:mc4,), Tuple{Vector{Any}}}}, config::SampleChainsDynamicHMC.DynamicHMCConfig{Tuple{}, Tuple{InitialStepsizeSearch, TuningNUTS{Nothing, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{LinearAlgebra.Diagonal, DualAveraging{Float64}}, TuningNUTS{Nothing, DualAveraging{Float64}}}, DynamicHMC.NUTS{Val{:generalized}}, NoProgressReport, Val{:ForwardDiff}}, nsamples::Int64, nchains::Int64)
   @ Soss ~/.julia/packages/Soss/cM22G/src/samplechains/dynamichmc.jl:20
 [7] sample (repeats 2 times)
   @ ~/.julia/packages/Soss/cM22G/src/samplechains/dynamichmc.jl:32 [inlined]
 [8] top-level scope
   @ REPL[16]:1

What am I doing wrong?

Julia Version 1.6.0

(sossTest) pkg> status
      Status `~/projects/sossTest/Project.toml`
  [31c24e10] Distributions v0.24.18
  [eadaa1a4] MeasureTheory v0.9.3
  [91a5bcdd] Plots v1.20.0
  [6d9fd711] SampleChainsDynamicHMC v0.3.3
  [8ce77f84] Soss v0.20.0
  [09ab397b] StructArrays v0.5.1
  [b8865327] UnicodePlots v1.3.0

Kind greetings, f.

cscherrer commented 3 years ago

Hi, sorry for the delay on this. This is really strange, especially since StructArrays in included as a dependency for SampleChainsDynamicHMC. Does the package manager otherwise seem happy? Have you tried ]resolve?

cscherrer commented 3 years ago

Oh, I guess the error is coming from TupleVectors, but StructArrays is a dependency there too. Can you do status -m?

FalkoSp commented 3 years ago

Btw, SampleChainsDynamicHMC gives a warning.

julia> using SampleChainsDynamicHMC
[ Info: Precompiling BenchmarkTools [6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf]
┌ Warning: Package Soss does not have SampleChainsDynamicHMC in its dependencies:
│ - If you have Soss checked out for development and have
│   added SampleChainsDynamicHMC as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with Soss
└ Loading SampleChainsDynamicHMC into Soss from project dependency, future warnings for Soss are suppressed.

status -m gives

(sosstest) pkg> status -m
      Status `C:\projects\sosstest\Manifest.toml`
  [c3fe647b] AbstractAlgebra v0.15.1
  [398f06c4] AbstractLattices v0.2.1
  [1520ce14] AbstractTrees v0.3.4
  [7d9f7c33] Accessors v0.1.4
  [79e6a3ab] Adapt v3.3.1
  [dce04be8] ArgCheck v2.1.0
  [4fba245c] ArrayInterface v3.1.17
  [4c555306] ArrayLayouts v0.7.3
  [65a8f2f4] ArraysOfArrays v0.5.3
  [198e06fe] BangBang v0.3.31
  [6e4b80f9] BenchmarkTools v0.7.0
  [336ed68f] CSV v0.8.5
  [49dc2e85] Calculus v0.5.1
  [d360d2e6] ChainRulesCore v1.3.0
  [35d6a980] ColorSchemes v3.14.0
  [3da002f7] ColorTypes v0.11.0
  [5ae59095] Colors v0.12.8
  [861a8166] Combinatorics v1.0.2
  [bbf7d656] CommonSubexpressions v0.3.0
  [34da2185] Compat v3.32.0
  [a33af91c] CompositionsBase v0.1.1
  [2569d6c7] ConcreteStructs v0.2.2
  [187b0558] ConstructionBase v1.3.0
  [d38c429a] Contour v0.5.7
  [a8cc5b0e] Crayons v4.0.4
  [9a962f9c] DataAPI v1.7.0
  [a93c6f00] DataFrames v1.2.2
  [864edb3b] DataStructures v0.18.10
  [e2d170a0] DataValueInterfaces v1.0.0
  [163ba53b] DiffResults v1.0.3
  [b552c78f] DiffRules v1.3.0
  [31c24e10] Distributions v0.24.18
  [ffbed154] DocStringExtensions v0.8.5
  [bbc10e6e] DynamicHMC v3.1.0
  [6c76993d] DynamicIterators v0.4.2
  [fdbdab4c] ElasticArrays v1.2.9
  [e2ba6199] ExprTools v0.1.6
  [c87230d0] FFMPEG v0.4.1
  [1a297f60] FillArrays v0.11.9
  [6a86dc24] FiniteDiff v2.8.1
  [53c48c17] FixedPointNumbers v0.8.4
  [b67e1e5a] FlexLinearAlgebra v0.1.0
  [59287772] Formatting v0.4.2
  [f6369f11] ForwardDiff v0.10.19
  [28b8d3ca] GR v0.58.1
  [6b9d7cbe] GeneralizedGenerated v0.3.2
  [5c1252a2] GeometryBasics v0.3.12
  [86223c79] Graphs v0.10.3
  [42e2da0e] Grisu v1.0.2
  [cd3eb016] HTTP v0.9.13
  [7869d1d1] IRTools v0.4.3
  [615f187c] IfElse v0.1.0
  [4858937d] InfiniteArrays v0.11.2
  [e1ba4f0e] Infinities v0.1.0
  [83e8ac13] IniFile v0.5.0
  [22cec73e] InitialValues v0.2.10
  [d8418881] Intervals v1.5.0
  [41ab1584] InvertedIndices v1.0.0
  [92d709cd] IrrationalConstants v0.1.0
  [c8e1da08] IterTools v1.3.0
  [82899510] IteratorInterfaceExtensions v1.0.0
  [692b3bcd] JLLWrappers v1.3.0
  [682c06a0] JSON v0.21.2
  [b14d175d] JuliaVariables v0.2.4
  [4d827475] KeywordCalls v0.2.2
  [b964fa9f] LaTeXStrings v1.2.1
  [2ee39098] LabelledArrays v1.6.4
  [23fbe1c1] Latexify v0.15.6
  [5078a376] LazyArrays v0.21.15
  [9c8b4983] LightXML v0.9.0
  [d3d80556] LineSearches v7.1.1
  [9b3f67b0] LinearAlgebraX v0.1.9
  [6fdf6af0] LogDensityProblems v0.10.6
  [2ab3a3ac] LogExpFunctions v0.3.0
  [6e857e4b] MCMCDiagnostics v0.3.0
  [d8e11817] MLStyle v0.4.10
  [1914dd2f] MacroTools v0.5.7
  [dbb5928d] MappedArrays v0.3.0
  [a3b82374] MatrixFactorizations v0.8.4
  [739be429] MbedTLS v1.0.3
  [eadaa1a4] MeasureTheory v0.10.1
  [eff96d63] Measurements v2.6.0
  [442fdcdd] Measures v0.3.1
  [e1d29d7a] Missings v1.0.0
  [78c3b35d] Mocking v0.7.2
  [7475f97c] Mods v1.3.1
  [3b2b4ff1] Multisets v0.4.2
  [d41bc354] NLSolversBase v7.8.1
  [77ba4419] NaNMath v0.3.5
  [71a1bf82] NameResolution v0.1.5
  [d9ec5142] NamedTupleTools v0.13.7
  [a734d2a7] NestedTuples v0.3.6
  [6fe1bfb0] OffsetArrays v1.10.5
  [429524aa] Optim v1.4.1
  [bac558e1] OrderedCollections v1.4.1
  [90014a1f] PDMats v0.11.1
  [d96e819e] Parameters v0.12.2
  [69de0a69] Parsers v1.1.2
  [2ae35dd2] Permutations v0.4.8
  [ccf2f8ad] PlotThemes v2.0.1
  [995b91a9] PlotUtils v1.0.11
  [91a5bcdd] Plots v1.20.1
  [f27b6e38] Polynomials v1.2.1
  [2dfb63ee] PooledArrays v1.2.1
  [85a6dd25] PositiveFactorizations v0.2.4
  [21216c6a] Preferences v1.2.2
  [8162dcfd] PrettyPrint v0.2.0
  [08abe8d2] PrettyTables v1.1.0
  [27ebfcd6] Primes v0.5.0
  [92933f4c] ProgressMeter v1.7.1
  [1fd47b50] QuadGK v2.4.1
  [fb686558] RandomExtensions v0.4.3
  [3cdcf5f2] RecipesBase v1.1.1
  [01d81517] RecipesPipeline v0.3.4
  [189a3867] Reexport v1.1.0
  [ae029012] Requires v1.1.3
  [286e9d63] RingLists v0.2.6
  [79098fc4] Rmath v0.7.0
  [7e49a35a] RuntimeGeneratedFunctions v0.5.3
  [754583d1] SampleChains v0.5.0
  [6d9fd711] SampleChainsDynamicHMC v0.3.3
  [6c6a2e73] Scratch v1.1.0
  [91c51154] SentinelArrays v1.3.6
  [efcf1570] Setfield v0.7.1
  [992d4aef] Showoff v1.0.3
  [55797a34] SimpleGraphs v0.7.9
  [ec83eff0] SimplePartitions v0.3.0
  [cc47b68c] SimplePolynomials v0.2.7
  [b2aef97b] SimplePosets v0.1.4
  [a6525b86] SimpleRandom v0.3.1
  [a2af1166] SortingAlgorithms v1.0.1
  [8ce77f84] Soss v0.20.2
  [276daf66] SpecialFunctions v1.6.1
  [aedffcd0] Static v0.2.5
  [90137ffa] StaticArrays v1.2.12
  [82ae8749] StatsAPI v1.0.0
  [2913bbd2] StatsBase v0.33.9
  [4c63d2b9] StatsFuns v0.9.9
  [09ab397b] StructArrays v0.5.1
  [fc9b0551] SymbolicCodegen v0.2.2
  [d1185830] SymbolicUtils v0.11.0
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.5.0
  [f269a46b] TimeZones v1.5.6
  [a759f4b9] TimerOutputs v0.5.12
  [2c80a279] Trajectories v0.2.2
  [84d833dd] TransformVariables v0.4.1
  [410a4b4d] Tricks v0.1.4
  [bc48ee85] Tullio v0.3.2
  [615932cf] TupleVectors v0.1.0
  [5c2747f8] URIs v1.3.0
  [3a884ed6] UnPack v1.0.2
  [c4a57d5a] UnsafeArrays v1.0.3
  [700de1a5] ZygoteRules v0.2.1
  [6e34b625] Bzip2_jll v1.0.6+5
  [83423d85] Cairo_jll v1.16.0+6
  [5ae413db] EarCut_jll v2.1.5+1
  [2e619515] Expat_jll v2.2.10+0
  [b22a6f82] FFMPEG_jll v4.3.1+4
  [a3f928ae] Fontconfig_jll v2.13.1+14
  [d7e528f0] FreeType2_jll v2.10.1+5
  [559328eb] FriBidi_jll v1.0.10+0
  [0656b61e] GLFW_jll v3.3.5+0
  [d2c73de3] GR_jll v0.58.1+0
  [78b55507] Gettext_jll v0.21.0+0
  [7746bdde] Glib_jll v2.68.3+0
  [aacddb02] JpegTurbo_jll v2.1.0+0
  [c1c5ebd0] LAME_jll v3.100.1+0
  [dd4b983a] LZO_jll v2.10.1+0
  [dd192d2f] LibVPX_jll v1.10.0+0
  [e9f186c6] Libffi_jll v3.2.2+0
  [d4300ac3] Libgcrypt_jll v1.8.7+0
  [7e76a0d4] Libglvnd_jll v1.3.0+3
  [7add5ba3] Libgpg_error_jll v1.42.0+0
  [94ce4f54] Libiconv_jll v1.16.1+1
  [4b2f31a3] Libmount_jll v2.35.0+0
  [89763e89] Libtiff_jll v4.3.0+0
  [38a345b3] Libuuid_jll v2.36.0+0
  [e7412a2a] Ogg_jll v1.3.5+0
  [458c3c95] OpenSSL_jll v1.1.10+0
  [efe28fd5] OpenSpecFun_jll v0.5.5+0
  [91d4177d] Opus_jll v1.3.2+0
  [2f80f16e] PCRE_jll v8.44.0+0
  [30392449] Pixman_jll v0.40.1+0
  [ea2cea3b] Qt5Base_jll v5.15.3+0
  [f50d1b31] Rmath_jll v0.3.0+0
  [a2964d1f] Wayland_jll v1.19.0+0
  [2381bf8a] Wayland_protocols_jll v1.18.0+4
  [02c8fc9c] XML2_jll v2.9.12+0
  [aed1982a] XSLT_jll v1.1.34+0
  [4f6342f7] Xorg_libX11_jll v1.6.9+4
  [0c0b7dd1] Xorg_libXau_jll v1.0.9+4
  [935fb764] Xorg_libXcursor_jll v1.2.0+4
  [a3789734] Xorg_libXdmcp_jll v1.1.3+4
  [1082639a] Xorg_libXext_jll v1.3.4+4
  [d091e8ba] Xorg_libXfixes_jll v5.0.3+4
  [a51aa0fd] Xorg_libXi_jll v1.7.10+4
  [d1454406] Xorg_libXinerama_jll v1.1.4+4
  [ec84b674] Xorg_libXrandr_jll v1.5.2+4
  [ea2f1a96] Xorg_libXrender_jll v0.9.10+4
  [14d82f49] Xorg_libpthread_stubs_jll v0.1.0+3
  [c7cfdc94] Xorg_libxcb_jll v1.13.0+3
  [cc61e674] Xorg_libxkbfile_jll v1.1.0+4
  [12413925] Xorg_xcb_util_image_jll v0.4.0+1
  [2def613f] Xorg_xcb_util_jll v0.4.0+1
  [975044d2] Xorg_xcb_util_keysyms_jll v0.4.0+1
  [0d47668e] Xorg_xcb_util_renderutil_jll v0.3.9+1
  [c22f9ab0] Xorg_xcb_util_wm_jll v0.4.1+1
  [35661453] Xorg_xkbcomp_jll v1.4.2+4
  [33bec58e] Xorg_xkeyboard_config_jll v2.27.0+4
  [c5fb5394] Xorg_xtrans_jll v1.4.0+3
  [3161d3a3] Zstd_jll v1.5.0+0
  [0ac62f75] libass_jll v0.14.0+4
  [f638f0a6] libfdk_aac_jll v0.1.6+4
  [b53b4c65] libpng_jll v1.6.38+0
  [f27f6e37] libvorbis_jll v1.3.7+0
  [1270edf5] x264_jll v2020.7.14+2
  [dfaa095f] x265_jll v3.0.0+3
  [d8fb68d0] xkbcommon_jll v0.9.1+5
  [0dad84c5] ArgTools
  [56f22d72] Artifacts
  [2a0f44e3] Base64
  [ade2ca70] Dates
  [8bb1440f] DelimitedFiles
  [8ba89e20] Distributed
  [f43a241f] Downloads
  [9fa8497b] Future
  [b77e0a4c] InteractiveUtils
  [4af54fe1] LazyArtifacts
  [b27032c2] LibCURL
  [76f85450] LibGit2
  [8f399da3] Libdl
  [37e2e46d] LinearAlgebra
  [56ddb016] Logging
  [d6f4376e] Markdown
  [a63ad114] Mmap
  [ca575930] NetworkOptions
  [44cfe95a] Pkg
  [de0858da] Printf
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA
  [9e88b42a] Serialization
  [1a1011a3] SharedArrays
  [6462fe0b] Sockets
  [2f01184e] SparseArrays
  [10745b16] Statistics
  [4607b0f0] SuiteSparse
  [fa267f1f] TOML
  [a4e569a6] Tar
  [8dfed614] Test
  [cf7118a7] UUIDs
  [4ec0a83e] Unicode
  [e66e0078] CompilerSupportLibraries_jll
  [deac9b47] LibCURL_jll
  [29816b5a] LibSSH2_jll
  [c8ffd9c3] MbedTLS_jll
  [14a3606d] MozillaCACerts_jll
  [83775a58] Zlib_jll
  [8e850ede] nghttp2_jll
  [3f19e933] p7zip_jll

(sosstest) pkg>                                                                                                         
FalkoSp commented 3 years ago

Ah, and when I directly include the code from https://github.com/cscherrer/Soss.jl/blob/master/src/samplechains/dynamichmc.jl, it works completely fine. Even in Pluto. I don't see why.

begin
using Random

using SampleChainsDynamicHMC:DynamicHMCConfig

function sample(rng::AbstractRNG, 
    m,#::ConditionalModel,
    config::DynamicHMCConfig, 
    nsamples::Int=1000,
    nchains::Int=4)

    ℓ(x) = Soss.logdensity(m, x)
    tr = xform(m)

    chains = newchain(rng, nchains, config, ℓ, tr)
    sample!(chains, nsamples - 1)
    return chains
end

function sample(
    m,#::ConditionalModel,
    config::DynamicHMCConfig, 
    nsamples::Int=1000,
    nchains::Int=4)

    sample(Random.GLOBAL_RNG, m, config, nsamples, nchains)
end
end
cscherrer commented 2 years ago

Hi @FalkoSp , I just realized this hasn't been resolved. Could you update your packages and try again? TupleVectors is currently at 0.1.2, so it's best to make sure you can use that release

cscherrer commented 2 years ago

@sethaxen may have fixed the problem in https://github.com/cscherrer/Soss.jl/pull/300

@FalkoSp @gzagatti could you try again with the latest version please?

sethaxen commented 2 years ago

Yes, that should fix the problem. I'd seen the error message for a while, but it caused Pluto to completely fail, which is what led me to fix it. Now I'm using Soss in Pluto with no problems.

cscherrer commented 2 years ago

This is great!!!

@FalkoSp and @gzagatti, if you can confirm when you have a chance, we can close this issue :)

FalkoSp commented 2 years ago

Thank you @sethaxen, thank you @cscherrer - works now!