Skip to content

Commit 1fcd16e

Browse files
authored
Cleanup Dependencies (#34)
* Remove `FillArrays`, `LogDensityProblemsAD`, `Requires`, `Accessors` `LogDensityProblemsAD` and `Requires` are not obsolete. `Accessors` is used only in one place for mutating an array, so it can be removed. The removal `FillArrays` will increase memory consumption for univariate slice samplers since we now maintain `d` copies of the univariate slice sampler object. However, since slice samplers are not expected to work for large `d`, this should be fine.
1 parent 39f06a4 commit 1fcd16e

File tree

4 files changed

+4
-40
lines changed

4 files changed

+4
-40
lines changed

Project.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
name = "SliceSampling"
22
uuid = "43f4d3e8-9711-4a8c-bd1b-03ac73a255cf"
3-
version = "0.7.4"
3+
version = "0.7.5"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
7-
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
87
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
9-
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
108
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
119
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
12-
LogDensityProblemsAD = "996a588d-648d-4e1f-a8f0-a84b347e47b1"
1310
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1411
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1512

@@ -21,14 +18,10 @@ SliceSamplingTuringExt = ["Turing"]
2118

2219
[compat]
2320
AbstractMCMC = "4, 5"
24-
Accessors = "0.1"
2521
Distributions = "0.25"
26-
FillArrays = "1"
2722
LinearAlgebra = "1"
2823
LogDensityProblems = "2"
29-
LogDensityProblemsAD = "1"
3024
Random = "1"
31-
Requires = "1"
3225
Turing = "0.37, 0.38"
3326
julia = "1.10"
3427

ext/SliceSamplingTuringExt.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
module SliceSamplingTuringExt
33

44
if isdefined(Base, :get_extension)
5-
using LogDensityProblemsAD
65
using Random
76
using SliceSampling
87
using Turing
98
else
10-
using ..LogDensityProblemsAD
119
using ..Random
1210
using ..SliceSampling
1311
using ..Turing

src/SliceSampling.jl

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22
module SliceSampling
33

44
using AbstractMCMC
5-
using Accessors
65
using Distributions
7-
using FillArrays
86
using LinearAlgebra
97
using LogDensityProblems
108
using Random
119

12-
# The following is necessary because Turing wraps all models with
13-
# LogDensityProblemsAD by default. So we need access to these types.
14-
using LogDensityProblemsAD
15-
1610
# reexports
1711
using AbstractMCMC: sample, MCMCThreads, MCMCDistributed, MCMCSerial
1812
export sample, MCMCThreads, MCMCDistributed, MCMCSerial
@@ -59,14 +53,6 @@ function initial_sample(::Random.AbstractRNG, ::Any)
5953
)
6054
end
6155

62-
# If target is from `LogDensityProblemsAD`, unwrap target before calling `initial_sample`.
63-
# This is necessary since Turing wraps `DynamicPPL.Model`s when passed to an `externalsampler`.
64-
function initial_sample(
65-
rng::Random.AbstractRNG, wrap::LogDensityProblemsAD.ADGradientWrapper
66-
)
67-
return initial_sample(rng, parent(wrap))
68-
end
69-
7056
function exceeded_max_prop(max_prop::Int)
7157
return error(
7258
"Exceeded maximum number of proposal $(max_prop), ",
@@ -116,18 +102,4 @@ include("multivariate/latent.jl")
116102
export GibbsPolarSlice
117103
include("multivariate/gibbspolar.jl")
118104

119-
# Turing Compatibility
120-
121-
if !isdefined(Base, :get_extension)
122-
using Requires
123-
end
124-
125-
@static if !isdefined(Base, :get_extension)
126-
function __init__()
127-
@require Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0" include(
128-
"../ext/SliceSamplingTuringExt.jl"
129-
)
130-
end
131-
end
132-
133105
end

src/multivariate/randpermgibbs.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ end
3838

3939
function LogDensityProblems.logdensity(gibbs::GibbsTarget, θi)
4040
(; model, idx, θ) = gibbs
41-
return LogDensityProblems.logdensity(model, (@set θ[idx] = θi))
41+
θ[idx] = θi
42+
return LogDensityProblems.logdensity(model, θ)
4243
end
4344

4445
function AbstractMCMC.step(
@@ -73,7 +74,7 @@ function AbstractMCMC.step(
7374
unislices = if sampler.unislice isa AbstractVector
7475
sampler.unislice
7576
else
76-
Fill(sampler.unislice, d)
77+
fill(sampler.unislice, d)
7778
end
7879

7980
props = zeros(Int, d)

0 commit comments

Comments
 (0)