Skip to content

Commit

Permalink
Merge a0c4da6 into 34899cf
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbates committed Jun 27, 2024
2 parents 34899cf + a0c4da6 commit 6ebbe75
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 6 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MixedModels v4.25.1 Release Notes
==============================
- Use more sophisticated checks on property names in `restoreoptsum` to allow for optsums saved by pre-v4.25 versions to be used with this version and later. [#775]

MixedModels v4.25 Release Notes
==============================
- Add type notations in `pwrss(::LinearMixedModel)` and `logdet(::LinearMixedModel)` to enhance type inference. [#773]
Expand Down Expand Up @@ -538,3 +542,4 @@ Package dependencies
[#769]: https://github.com/JuliaStats/MixedModels.jl/issues/769
[#772]: https://github.com/JuliaStats/MixedModels.jl/issues/772
[#773]: https://github.com/JuliaStats/MixedModels.jl/issues/773
[#775]: https://github.com/JuliaStats/MixedModels.jl/issues/775
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MixedModels"
uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
author = ["Phillip Alday <me@phillipalday.com>", "Douglas Bates <dmbates@gmail.com>", "Jose Bayoan Santiago Calderon <jbs3hp@virginia.edu>"]
version = "4.25.0"
version = "4.25.1"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
20 changes: 15 additions & 5 deletions src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ function restoreoptsum!(
) where {T}
dict = JSON3.read(io)
ops = m.optsum
okay =
(setdiff(propertynames(ops), keys(dict)) == [:lowerbd]) &&
all(ops.lowerbd .≤ dict.initial) &&
all(ops.lowerbd .≤ dict.final)
if !okay
nmdiff = setdiff(
propertynames(ops), # names in freshly created optsum
union!( # names in saved optsum plus those we allow to be missing
Set(keys(dict)),
(
:lowerbd, # never saved, -Inf not allowed in JSON
:xtol_zero_abs, # added in v4.25.0
:ftol_zero_abs, # added in v4.25.0
),
),
)
if !isempty(nmdiff)
throw(ArgumentError(string("optsum names:", nmdiff, " not found in io")))
end
if any(ops.lowerbd .> dict.initial) || any(ops.lowerbd .> dict.final)
throw(ArgumentError("initial or final parameters in io do not satisfy lowerbd"))
end
for fld in (:feval, :finitial, :fmin, :ftol_rel, :ftol_abs, :maxfeval, :nAGQ, :REML)
Expand Down
84 changes: 84 additions & 0 deletions test/pls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,90 @@ end
@test loglikelihood(fm) loglikelihood(m)
@test bic(fm) bic(m)
@test coef(fm) coef(m)

# check restoreoptsum from v4.23.1
m = LinearMixedModel(
@formula(reaction ~ 1 + days + (1 + days | subj)),
MixedModels.dataset(:sleepstudy),
)
iob = IOBuffer(
"""
{
"initial":[1.0,0.0,1.0],
"finitial":1784.642296192436,
"ftol_rel":1.0e-12,
"ftol_abs":1.0e-8,
"xtol_rel":0.0,
"xtol_abs":[1.0e-10,1.0e-10,1.0e-10],
"initial_step":[0.75,1.0,0.75],
"maxfeval":-1,
"maxtime":-1.0,
"feval":57,
"final":[0.9292213195402981,0.01816837807519162,0.22264487477788353],
"fmin":1751.9393444646712,
"optimizer":"LN_BOBYQA",
"returnvalue":"FTOL_REACHED",
"nAGQ":1,
"REML":false,
"sigma":null,
"fitlog":[[[1.0,0.0,1.0],1784.642296192436]]
}
"""
)
restoreoptsum!(m, seekstart(iob))
@test loglikelihood(fm) loglikelihood(m)
@test bic(fm) bic(m)
@test coef(fm) coef(m)
iob = IOBuffer(
"""
{
"initial":[1.0,0.0,1.0],
"finitial":1784.642296192436,
"ftol_rel":1.0e-12,
"xtol_rel":0.0,
"xtol_abs":[1.0e-10,1.0e-10,1.0e-10],
"initial_step":[0.75,1.0,0.75],
"maxfeval":-1,
"maxtime":-1.0,
"feval":57,
"final":[0.9292213195402981,0.01816837807519162,0.22264487477788353],
"fmin":1751.9393444646712,
"optimizer":"LN_BOBYQA",
"returnvalue":"FTOL_REACHED",
"nAGQ":1,
"REML":false,
"sigma":null,
"fitlog":[[[1.0,0.0,1.0],1784.642296192436]]
}
"""
)
@test_throws ArgumentError restoreoptsum!(m, seekstart(iob))

iob = IOBuffer(
"""
{
"initial":[1.0,0.0,1.0],
"finitial":1784.642296192436,
"ftol_rel":1.0e-12,
"ftol_abs":1.0e-8,
"xtol_rel":0.0,
"xtol_abs":[1.0e-10,1.0e-10,1.0e-10],
"initial_step":[0.75,1.0,0.75],
"maxfeval":-1,
"maxtime":-1.0,
"feval":57,
"final":[-0.9292213195402981,0.01816837807519162,0.22264487477788353],
"fmin":1751.9393444646712,
"optimizer":"LN_BOBYQA",
"returnvalue":"FTOL_REACHED",
"nAGQ":1,
"REML":false,
"sigma":null,
"fitlog":[[[1.0,0.0,1.0],1784.642296192436]]
}
"""
)
@test_throws ArgumentError restoreoptsum!(m, seekstart(iob))
end

@testset "profile" begin
Expand Down

0 comments on commit 6ebbe75

Please sign in to comment.