Skip to content

Commit 46014a9

Browse files
committed
Remove Optim.jl extension
1 parent be007f3 commit 46014a9

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
@@ -19,28 +19,26 @@ using Statistics: Statistics
1919
using LinearAlgebra: LinearAlgebra
2020

2121
export maximum_a_posteriori, maximum_likelihood
22-
# The MAP and MLE exports are only needed for the Optim.jl interface.
23-
export MAP, MLE
2422

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

3331
"""
3432
MLE <: ModeEstimator
3533
36-
Concrete type for maximum likelihood estimation. Only used for the Optim.jl interface.
34+
Concrete type for maximum likelihood estimation.
3735
"""
3836
struct MLE <: ModeEstimator end
3937

4038
"""
4139
MAP <: ModeEstimator
4240
43-
Concrete type for maximum a posteriori estimation. Only used for the Optim.jl interface.
41+
Concrete type for maximum a posteriori estimation.
4442
"""
4543
struct MAP <: ModeEstimator end
4644

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

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

0 commit comments

Comments
 (0)