Skip to content

Commit 6bceedb

Browse files
committed
Remove Optim.jl extension
1 parent ea9bb54 commit 6bceedb

File tree

3 files changed

+3
-236
lines changed

3 files changed

+3
-236
lines changed

Project.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
4141

4242
[weakdeps]
4343
DynamicHMC = "bbc10e6e-7c05-544b-b16e-64fede858acb"
44-
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
4544

4645
[extensions]
4746
TuringDynamicHMCExt = "DynamicHMC"
48-
TuringOptimExt = ["Optim", "AbstractPPL"]
4947

5048
[compat]
5149
ADTypes = "1.9"
@@ -72,7 +70,6 @@ LinearAlgebra = "1"
7270
LogDensityProblems = "2"
7371
MCMCChains = "5, 6, 7"
7472
NamedArrays = "0.9, 0.10"
75-
Optim = "1"
7673
Optimization = "3, 4, 5"
7774
OptimizationOptimJL = "0.1, 0.2, 0.3, 0.4"
7875
OrderedCollections = "1"
@@ -86,7 +83,3 @@ StatsAPI = "1.6"
8683
StatsBase = "0.32, 0.33, 0.34"
8784
StatsFuns = "0.8, 0.9, 1"
8885
julia = "1.10.8"
89-
90-
[extras]
91-
DynamicHMC = "bbc10e6e-7c05-544b-b16e-64fede858acb"
92-
Optim = "429524aa-4258-5aef-a3af-852621145aeb"

ext/TuringOptimExt.jl

Lines changed: 0 additions & 198 deletions
This file was deleted.

src/optimisation/Optimisation.jl

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,26 @@ using Statistics: Statistics
2020
using LinearAlgebra: LinearAlgebra
2121

2222
export maximum_a_posteriori, maximum_likelihood
23-
# The MAP and MLE exports are only needed for the Optim.jl interface.
24-
export MAP, MLE
2523

2624
"""
2725
ModeEstimator
2826
2927
An abstract type to mark whether mode estimation is to be done with maximum a posteriori
30-
(MAP) or maximum likelihood estimation (MLE). This is only needed for the Optim.jl interface.
28+
(MAP) or maximum likelihood estimation (MLE).
3129
"""
3230
abstract type ModeEstimator end
3331

3432
"""
3533
MLE <: ModeEstimator
3634
37-
Concrete type for maximum likelihood estimation. Only used for the Optim.jl interface.
35+
Concrete type for maximum likelihood estimation.
3836
"""
3937
struct MLE <: ModeEstimator end
4038

4139
"""
4240
MAP <: ModeEstimator
4341
44-
Concrete type for maximum a posteriori estimation. Only used for the Optim.jl interface.
42+
Concrete type for maximum a posteriori estimation.
4543
"""
4644
struct MAP <: ModeEstimator end
4745

@@ -124,32 +122,6 @@ required by Optimization.jl.
124122
(f::OptimLogDensity)(z::AbstractVector) = -LogDensityProblems.logdensity(f.ldf, z)
125123
(f::OptimLogDensity)(z, _) = f(z)
126124

127-
# NOTE: The format of this function is dictated by Optim. The first argument sets whether to
128-
# compute the function value, the second whether to compute the gradient (and stores the
129-
# gradient). The last one is the actual argument of the objective function.
130-
function (f::OptimLogDensity)(F, G, z)
131-
if G !== nothing
132-
# Calculate log joint and its gradient.
133-
logp, ∇logp = LogDensityProblems.logdensity_and_gradient(f.ldf, z)
134-
135-
# Save the negative gradient to the pre-allocated array.
136-
copyto!(G, -∇logp)
137-
138-
# If F is something, the negative log joint is requested as well.
139-
# We have already computed it as a by-product above and hence return it directly.
140-
if F !== nothing
141-
return -logp
142-
end
143-
end
144-
145-
# Only negative log joint requested but no gradient.
146-
if F !== nothing
147-
return -LogDensityProblems.logdensity(f.ldf, z)
148-
end
149-
150-
return nothing
151-
end
152-
153125
"""
154126
ModeResult{
155127
V<:NamedArrays.NamedArray,

0 commit comments

Comments
 (0)