Skip to content

Commit

Permalink
Upgrade to ManifoldDiff v0.4 (#771)
Browse files Browse the repository at this point in the history
* Upgrade to next ManifoldsDiff with DI integration

* Custom ManifoldsDiff in CI

* Upgrade Julia compat to 1.10

* Bump Julia compat to 1.10

* Remove backends

* Remove Requires

* Remove Requires

* Remove access to FDM method

* Format

* Remove Pkg tricks

* Changelog
  • Loading branch information
gdalle authored Nov 27, 2024
1 parent bcbc7d2 commit 66be9cc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Some methods related to `get_vector` for `GeneralUnitaryMatrices` now have `AbstractVector` upper bound for coefficients.
* Minimum Julia version is now 1.10 (the LTS which replaced 1.6)
* The dependency ManifoldDiff.jl has been upgraded from v0.3 to v0.4, to bring compatibility with DifferentiationInterface.jl.

## [0.10.7] – 2024-11-16

Expand Down
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Graphs = "1.4"
HybridArrays = "0.4"
Kronecker = "0.4, 0.5"
LinearAlgebra = "1.6"
ManifoldDiff = "0.3.13"
ManifoldDiff = "0.4.0"
ManifoldsBase = "0.15.18"
Markdown = "1.6"
MatrixEquations = "2.2"
Expand All @@ -74,6 +74,7 @@ StatsBase = "0.32, 0.33, 0.34"
julia = "1.10"

[extras]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
BoundaryValueDiffEq = "764a87c0-6b3e-53db-9096-fe964310641d"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
Expand All @@ -98,4 +99,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"

[targets]
test = ["Test", "BoundaryValueDiffEq", "Colors", "DiffEqCallbacks", "Distributions", "DoubleFloats", "FiniteDifferences", "Gtk", "HybridArrays", "ImageIO", "ImageMagick", "OrdinaryDiffEq", "NLsolve", "Plots", "PythonPlot", "Quaternions", "QuartzImageIO", "RecipesBase", "RecursiveArrayTools"]
test = ["Test", "ADTypes", "BoundaryValueDiffEq", "Colors", "DiffEqCallbacks", "Distributions", "DoubleFloats", "FiniteDifferences", "Gtk", "HybridArrays", "ImageIO", "ImageMagick", "OrdinaryDiffEq", "NLsolve", "Plots", "PythonPlot", "Quaternions", "QuartzImageIO", "RecipesBase", "RecursiveArrayTools"]
3 changes: 2 additions & 1 deletion src/Manifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ using ManifoldDiff:
_jacobian!,
set_default_differential_backend!
using ManifoldDiff:
AbstractDiffBackend,
AbstractRiemannianDiffBackend,
CoprojectorOntoVector,
ExplicitEmbeddedBackend,
Expand All @@ -365,6 +364,8 @@ using Statistics
using StatsBase
using StatsBase: AbstractWeights

const AbstractDiffBackend = Any # TODO: remove

include("utils.jl")

include("manifold_fallbacks.jl")
Expand Down
13 changes: 7 additions & 6 deletions test/differentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ function ManifoldDiff.gradient(::AbstractManifold, f, p, ::TestRiemannianBackend
return collect(1.0:length(p))
end

using ADTypes
using FiniteDifferences
using LinearAlgebra: Diagonal, dot

@testset "Differentiation backend" begin
fd51 = ManifoldDiff.FiniteDifferencesBackend()
fd51 = AutoFiniteDifferences(central_fdm(5, 1))
@testset "default_differential_backend" begin
@test default_differential_backend() isa ManifoldDiff.FiniteDifferencesBackend
@test default_differential_backend() isa AutoFiniteDifferences

@test length(fd51.method.grid) == 5
@test length(fd51.fdm.grid) == 5
# check method order
@test typeof(fd51.method).parameters[2] == 1
fd71 = ManifoldDiff.FiniteDifferencesBackend(central_fdm(7, 1))
@test typeof(fd51.fdm).parameters[2] == 1
fd71 = AutoFiniteDifferences(central_fdm(7, 1))
@test set_default_differential_backend!(fd71) == fd71
@test default_differential_backend() == fd71
end
Expand Down Expand Up @@ -105,7 +106,7 @@ rb_onb_default = TangentDiffBackend(
DefaultOrthonormalBasis(),
)

rb_onb_fd51 = TangentDiffBackend(ManifoldDiff.FiniteDifferencesBackend())
rb_onb_fd51 = TangentDiffBackend(AutoFiniteDifferences(central_fdm(5, 1)))

rb_onb_default2 = TangentDiffBackend(
default_differential_backend();
Expand Down
2 changes: 1 addition & 1 deletion test/manifolds/symplectic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ using ManifoldDiff
analytical_grad_f(p) = (1 / 2) * (p * J * p * J + p * p')

p_grad = points[1]
fd_diff = RiemannianProjectionBackend(ManifoldDiff.FiniteDifferencesBackend())
fd_diff = RiemannianProjectionBackend(AutoFiniteDifferences(central_fdm(5, 1)))

@test isapprox(
Manifolds.gradient(Sp_6, test_f, p_grad, fd_diff),
Expand Down
2 changes: 1 addition & 1 deletion test/manifolds/symplecticstiefel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ end
return Q_grad * p * (euc_grad_f') * Q_grad * p + euc_grad_f * p' * p
end
p_grad = convert(Array{Float64}, points[1])
fd_diff = RiemannianProjectionBackend(ManifoldDiff.FiniteDifferencesBackend())
fd_diff = RiemannianProjectionBackend(AutoFiniteDifferences(central_fdm(5, 1)))

@test isapprox(
Manifolds.gradient(M, test_f, p_grad, fd_diff),
Expand Down
6 changes: 3 additions & 3 deletions test/metric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using ManifoldsBase: TraitList
import ManifoldsBase: default_retraction_method
import Manifolds: solve_exp_ode
using Manifolds: InducedBasis, connection, get_chart_index, induced_basis, mean!, median!
using ManifoldDiff: FiniteDifferencesBackend
using ADTypes
include("header.jl")

struct TestEuclidean{N} <: AbstractManifold{ℝ} end
Expand Down Expand Up @@ -372,7 +372,7 @@ Manifolds.inner(::MetricManifold{ℝ,<:AbstractManifold{ℝ},Issue539Metric}, p,
@test gaussian_curvature(M, p, B_chart_p) 0 atol = 1e-6
@test einstein_tensor(M, p, B_chart_p) zeros(n, n) atol = 1e-6

fdm = FiniteDifferencesBackend(forward_fdm(2, 1))
fdm = AutoFiniteDifferences(forward_fdm(2, 1))
@test christoffel_symbols_first(M, p, B_chart_p; backend=fdm) zeros(n, n, n) atol =
1e-6
@test christoffel_symbols_second(M, p, B_chart_p; backend=fdm) zeros(n, n, n) atol =
Expand All @@ -384,7 +384,7 @@ Manifolds.inner(::MetricManifold{ℝ,<:AbstractManifold{ℝ},Issue539Metric}, p,
@test gaussian_curvature(M, p, B_chart_p; backend=fdm) 0 atol = 1e-6
@test einstein_tensor(M, p, B_chart_p; backend=fdm) zeros(n, n) atol = 1e-6

fd_diff = FiniteDifferencesBackend()
fd_diff = AutoFiniteDifferences(central_fdm(5, 1))
@test christoffel_symbols_first(M, p, B_chart_p; backend=fd_diff)
zeros(n, n, n) atol = 1e-6
@test christoffel_symbols_second(M, p, B_chart_p; backend=fd_diff)
Expand Down

2 comments on commit 66be9cc

@mateuszbaran
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

Changed

  • Some methods related to get_vector for GeneralUnitaryMatrices now have AbstractVector upper bound for coefficients.
  • Minimum Julia version is now 1.10 (the LTS which replaced 1.6)
  • The dependency ManifoldDiff.jl has been upgraded from v0.3 to v0.4, to bring compatibility with DifferentiationInterface.jl.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120289

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.8 -m "<description of version>" 66be9ccaa540f56746a8e1c134dd45be4a72e990
git push origin v0.10.8

Please sign in to comment.