Skip to content

Commit 9087412

Browse files
devmotiontorfjelde
andauthored
Rename Turing.Core to Turing.Essential (#1762)
* Rename `Turing.Core` to `Turing.Essential` * Deprecate Turing.Core Co-authored-by: Tor Erlend Fjelde <[email protected]> Co-authored-by: Tor Erlend Fjelde <[email protected]>
1 parent ac99fb0 commit 9087412

File tree

11 files changed

+31
-30
lines changed

11 files changed

+31
-30
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Turing"
22
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
3-
version = "0.19.3"
3+
version = "0.19.4"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

docs/src/library/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CurrentModule = Turing
1010
## Index
1111

1212
```@index
13-
Modules = [Turing, Turing.Core, Turing.Inference, Libtask]
13+
Modules = [Turing, Turing.Essential, Turing.Inference, Libtask]
1414
```
1515

1616
## Modelling

src/Turing.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ include("stdlib/distributions.jl")
3030
include("stdlib/RandomMeasures.jl")
3131
include("utilities/Utilities.jl")
3232
using .Utilities
33-
include("core/Core.jl")
34-
using .Core
33+
include("essential/Essential.jl")
34+
Base.@deprecate_binding Core Essential false
35+
using .Essential
3536
include("inference/Inference.jl") # inference algorithms
3637
using .Inference
3738
include("variational/VariationalInference.jl")
@@ -140,7 +141,7 @@ export @model, # modelling
140141
MAP,
141142
MLE,
142143
get_parameter_bounds,
143-
optim_objective,
144+
optim_objective,
144145
optim_function,
145146
optim_problem
146147
end

src/core/Core.jl renamed to src/essential/Essential.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Core
1+
module Essential
22

33
using DistributionsAD, Bijectors
44
using Libtask, ForwardDiff, Random
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/inference/AdvancedSMC.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,6 @@ function AdvancedPS.Trace(
365365
)
366366
newvarinfo = deepcopy(varinfo)
367367
DynamicPPL.reset_num_produce!(newvarinfo)
368-
f = Turing.Core.TracedModel(model, sampler, newvarinfo)
368+
f = Turing.Essential.TracedModel(model, sampler, newvarinfo)
369369
return AdvancedPS.Trace(f)
370370
end

src/inference/Inference.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module Inference
22

3-
using ..Core
3+
using ..Essential
44
using ..Utilities
5-
using DynamicPPL: Metadata, VarInfo, TypedVarInfo,
5+
using DynamicPPL: Metadata, VarInfo, TypedVarInfo,
66
islinked, invlink!, link!,
77
setindex!!, push!!,
88
setlogp!!, getlogp,
@@ -28,7 +28,7 @@ import AdvancedHMC; const AHMC = AdvancedHMC
2828
import AdvancedMH; const AMH = AdvancedMH
2929
import AdvancedPS
3030
import BangBang
31-
import ..Core: getchunksize, getADbackend
31+
import ..Essential: getchunksize, getADbackend
3232
import EllipticalSliceSampling
3333
import Random
3434
import MCMCChains
@@ -260,7 +260,7 @@ function _params_to_array(ts::Vector)
260260
return Dict(nms[j] => vs[j] for j in 1:length(vs))
261261
end
262262
names = collect(names_set)
263-
vals = [get(dicts[i], key, missing) for i in eachindex(dicts),
263+
vals = [get(dicts[i], key, missing) for i in eachindex(dicts),
264264
(j, key) in enumerate(names)]
265265

266266
return names, vals
@@ -444,7 +444,7 @@ for alg in (:HMC, :HMCDA, :NUTS, :SGLD, :SGHMC)
444444
end
445445

446446
function DynamicPPL.get_matching_type(
447-
spl::Sampler{<:Union{PG, SMC}},
447+
spl::Sampler{<:Union{PG, SMC}},
448448
vi,
449449
::Type{TV},
450450
) where {T, N, TV <: Array{T, N}}
@@ -566,8 +566,8 @@ end
566566
567567
transitions_from_chain(
568568
[rng::AbstractRNG,]
569-
model::Model,
570-
chain::MCMCChains.Chains;
569+
model::Model,
570+
chain::MCMCChains.Chains;
571571
sampler = DynamicPPL.SampleFromPrior()
572572
)
573573

test/core/ad.jl renamed to test/essential/ad.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@
7777
sample(dir(), HMC(0.01, 1), 1000);
7878
Turing.setrdcache(true)
7979
sample(dir(), HMC(0.01, 1), 1000);
80-
caches = Memoization.find_caches(Turing.Core.memoized_taperesult)
80+
caches = Memoization.find_caches(Turing.Essential.memoized_taperesult)
8181
@test length(caches) == 1
8282
@test !isempty(first(values(caches)))
8383
Turing.emptyrdcache()
84-
caches = Memoization.find_caches(Turing.Core.memoized_taperesult)
84+
caches = Memoization.find_caches(Turing.Essential.memoized_taperesult)
8585
@test length(caches) == 1
8686
@test isempty(first(values(caches)))
8787
end
@@ -111,35 +111,35 @@
111111
@model function tst(x, ::Type{TV}=Vector{Float64}) where {TV}
112112
params = TV(undef, 2)
113113
@. params ~ Normal(0, 1)
114-
114+
115115
x ~ MvNormal(params, I)
116116
end
117-
117+
118118
function make_logjoint(model::DynamicPPL.Model, ctx::DynamicPPL.AbstractContext)
119119
# setup
120120
varinfo_init = Turing.VarInfo(model)
121-
spl = DynamicPPL.SampleFromPrior()
121+
spl = DynamicPPL.SampleFromPrior()
122122
DynamicPPL.link!(varinfo_init, spl)
123-
123+
124124
function logπ(z; unlinked = false)
125125
varinfo = DynamicPPL.VarInfo(varinfo_init, spl, z)
126-
126+
127127
unlinked && DynamicPPL.invlink!(varinfo_init, spl)
128128
model(varinfo, spl, ctx)
129129
unlinked && DynamicPPL.link!(varinfo_init, spl)
130-
130+
131131
return -DynamicPPL.getlogp(varinfo)
132132
end
133-
133+
134134
return logπ
135135
end
136-
136+
137137
data = [0.5, -0.5]
138138
model = tst(data)
139-
139+
140140
likelihood = make_logjoint(model, DynamicPPL.LikelihoodContext())
141141
target(x) = likelihood(x, unlinked=true)
142-
142+
143143
H_f = ForwardDiff.hessian(target, zeros(2))
144144
H_r = ReverseDiff.hessian(target, zeros(2))
145145
@test H_f == [1.0 0.0; 0.0 1.0]

0 commit comments

Comments
 (0)