Skip to content

Restore Optim 2 compatibility in optimize!#241

Open
orebas wants to merge 1 commit into
STOR-i:masterfrom
orebas:optim2-compat
Open

Restore Optim 2 compatibility in optimize!#241
orebas wants to merge 1 commit into
STOR-i:masterfrom
orebas:optim2-compat

Conversation

@orebas
Copy link
Copy Markdown
Contributor

@orebas orebas commented May 7, 2026

Summary

Restores optimize! under Optim 2.x while keeping Optim 1.x working.

Changes

  • src/optimize.jl — pass method positionally instead of as a keyword. Optim 2 removed the method= form; positional works under both Optim 1 and 2.
  • src/GPE.jl — narrow ldiv!(cK::PDMat, x) to x::AbstractVecOrMat. Recent PDMats added a generic ldiv! that was ambiguous with the previous loose form.
  • Project.toml — bump Optim compat to "1, 2".

Repro on upstream master

using GaussianProcesses, Random
gp = GPE(rand(2, 20), randn(20), MeanLin(zeros(2)), SE(0.0, 1.0), -3.0)
optimize!(gp)  # MethodError under Optim 2

Test plan

  • Reproduced the failure on upstream master under Optim 2.0.1
  • All four call patterns from test/optim.jl work end-to-end under Optim 2.0.1 + PDMats 0.11.37
  • Backward-compatible with Optim 1.x

Note

A separate Optim 2 issue remains: kwarg shortcuts like optimize!(gp; iterations=50) now need Optim.Options(iterations=50). Not exercised by existing tests; can file a follow-up.

- src/optimize.jl: pass `method` positionally; Optim 2 removed the keyword shim.
- src/GPE.jl: narrow the `ldiv!(::PDMat, x)` second arg to `AbstractVecOrMat`
  so it isn't ambiguous with PDMats' new generic `ldiv!`.
- Project.toml: bump Optim compat from "1.13" to "1, 2".

Backward-compatible with Optim 1.x.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@orebas orebas changed the title Use positional method argument for Optim 2 compatibility Restore Optim 2 compatibility in optimize! May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant