Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 67 additions & 10 deletions lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down Expand Up @@ -93,14 +105,26 @@ end
using ADTypes, Random, LinearSolve, LinearAlgebra
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

preconditioners = [
(u0) -> nothing,
u0 -> ((args...) -> (Diagonal(rand!(similar(u0))), nothing))
]

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)

@testset "[OOP] u0: $(typeof(u0))" for u0 in u0s
Expand Down Expand Up @@ -176,15 +200,27 @@ end
using ADTypes, LinearSolve, LinearAlgebra
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

radius_update_schemes = [
RadiusUpdateSchemes.Simple, RadiusUpdateSchemes.NocedalWright,
RadiusUpdateSchemes.NLsolve, RadiusUpdateSchemes.Hei,
RadiusUpdateSchemes.Yuan, RadiusUpdateSchemes.Fan, RadiusUpdateSchemes.Bastin
]

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset for radius_update_scheme in radius_update_schemes,
linsolve in (nothing, LUFactorization(), KrylovJL_GMRES(), \)

Expand Down Expand Up @@ -296,9 +332,21 @@ end
using ADTypes, LinearSolve, LinearAlgebra
using BenchmarkTools: @ballocated
using StaticArrays: SVector, @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
solver = LevenbergMarquardt(; autodiff = ad)

@testset "[OOP] u0: $(typeof(u0))" for u0 in ([1.0, 1.0], 1.0, @SVector([1.0, 1.0]))
Expand Down Expand Up @@ -394,8 +442,17 @@ end

@testitem "Simple Sparse AutoDiff" setup=[CoreRootfindTesting] tags=[:core] begin
using ADTypes, SparseConnectivityTracer, SparseMatrixColorings

@testset for ad in (AutoForwardDiff(), AutoFiniteDiff(), AutoZygote(), AutoEnzyme())

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Include utility functions for prerelease detection
include("test_utilities.jl")

# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoFiniteDiff(), AutoZygote()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset for u0 in ([1.0, 1.0], 1.0)
prob = NonlinearProblem(
NonlinearFunction(quadratic_f; sparsity = TracerSparsityDetector()), u0, 2.0
Expand Down
30 changes: 30 additions & 0 deletions lib/NonlinearSolveFirstOrder/test/test_utilities.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Test utilities for NonlinearSolveFirstOrder

"""
is_julia_prerelease()

Check if the current Julia version is a prerelease version (e.g., DEV, alpha, beta, rc).
"""
function is_julia_prerelease()
version_string = string(VERSION)
# Check for DEV versions (e.g., "1.12.0-DEV.1234")
contains(version_string, "DEV") && return true
# Check for alpha/beta/rc versions
contains(version_string, "alpha") && return true
contains(version_string, "beta") && return true
contains(version_string, "rc") && return true
return false
end

"""
filter_autodiff_backends(backends)

Filter out AutoEnzyme from the list of autodiff backends if running on Julia prerelease.
"""
function filter_autodiff_backends(backends)
if is_julia_prerelease()
return filter(ad -> !isa(ad, AutoEnzyme), backends)
else
return backends
end
end
33 changes: 24 additions & 9 deletions lib/NonlinearSolveHomotopyContinuation/test/allroots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ using NonlinearSolve
using NonlinearSolveHomotopyContinuation
using SciMLBase: NonlinearSolution
using ADTypes
using Enzyme
import NaNMath

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

alg = HomotopyContinuationJL{true}(; threading = false)

@testset "scalar u" begin
Expand All @@ -14,9 +19,13 @@ alg = HomotopyContinuationJL{true}(; threading = false)
jac = function (u, p)
return 2u - p[1]
end
@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in [
(AutoForwardDiff(), "no jac - forwarddiff"), (AutoEnzyme(), "no jac - enzyme"), (
jac, "jac")]
# Filter autodiff backends based on Julia version
autodiff_backends = [(AutoForwardDiff(), "no jac - forwarddiff"), (jac, "jac")]
if !is_julia_prerelease()
push!(autodiff_backends, (AutoEnzyme(), "no jac - enzyme"))
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in autodiff_backends
if jac_or_autodiff isa Function
jac = jac_or_autodiff
autodiff = nothing
Expand Down Expand Up @@ -107,11 +116,17 @@ fjac = function (u, p)
2*p[2]*u[2] 3*u[2]^2+2*p[2]*u[1]+1]
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, AutoEnzyme(), "oop + enzyme"), (
f, fjac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, AutoEnzyme(), "iip + enzyme"), (
f!, fjac!, "iip + jac")]
# Filter test cases based on Julia version
vector_test_cases = [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, fjac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, fjac!, "iip + jac")
]
if !is_julia_prerelease()
push!(vector_test_cases, (f, AutoEnzyme(), "oop + enzyme"))
push!(vector_test_cases, (f!, AutoEnzyme(), "iip + enzyme"))
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in vector_test_cases
sol = nothing
if jac_or_autodiff isa Function
jac = jac_or_autodiff
Expand Down
29 changes: 21 additions & 8 deletions lib/NonlinearSolveHomotopyContinuation/test/single_root.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ using NonlinearSolveHomotopyContinuation
using SciMLBase: NonlinearSolution
import NaNMath

# Include utility functions for prerelease detection
include("test_utilities.jl")

alg = HomotopyContinuationJL{false}(; threading = false)

@testset "scalar u" begin
Expand All @@ -12,9 +15,13 @@ alg = HomotopyContinuationJL{false}(; threading = false)
jac = function (u, p)
return 2u - (p + 3)
end
@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in [
(AutoForwardDiff(), "no jac - forwarddiff"), (AutoEnzyme(), "no jac - enzyme"), (
jac, "jac")]
# Filter autodiff backends based on Julia version
autodiff_backends = [(AutoForwardDiff(), "no jac - forwarddiff"), (jac, "jac")]
if !is_julia_prerelease()
push!(autodiff_backends, (AutoEnzyme(), "no jac - enzyme"))
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset "`NonlinearProblem` - $name" for (jac_or_autodiff, name) in autodiff_backends
if jac_or_autodiff isa Function
jac = jac_or_autodiff
autodiff = nothing
Expand Down Expand Up @@ -96,11 +103,17 @@ jac = function (u, p)
2*p[2]*u[2] 3*u[2]^2+2*p[2]*u[1]+1]
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, AutoEnzyme(), "oop + enzyme"), (
f, jac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, AutoEnzyme(), "iip + enzyme"), (
f!, jac!, "iip + jac")]
# Filter test cases based on Julia version
vector_test_cases = [
(f, AutoForwardDiff(), "oop + forwarddiff"), (f, jac, "oop + jac"),
(f!, AutoForwardDiff(), "iip + forwarddiff"), (f!, jac!, "iip + jac")
]
if !is_julia_prerelease()
push!(vector_test_cases, (f, AutoEnzyme(), "oop + enzyme"))
push!(vector_test_cases, (f!, AutoEnzyme(), "iip + enzyme"))
end

@testset "vector u - $name" for (rhs, jac_or_autodiff, name) in vector_test_cases
if jac_or_autodiff isa Function
jac = jac_or_autodiff
autodiff = nothing
Expand Down
17 changes: 17 additions & 0 deletions lib/NonlinearSolveHomotopyContinuation/test/test_utilities.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Test utilities for NonlinearSolveHomotopyContinuation

"""
is_julia_prerelease()

Check if the current Julia version is a prerelease version (e.g., DEV, alpha, beta, rc).
"""
function is_julia_prerelease()
version_string = string(VERSION)
# Check for DEV versions (e.g., "1.12.0-DEV.1234")
contains(version_string, "DEV") && return true
# Check for alpha/beta/rc versions
contains(version_string, "alpha") && return true
contains(version_string, "beta") && return true
contains(version_string, "rc") && return true
return false
end
48 changes: 42 additions & 6 deletions lib/NonlinearSolveQuasiNewton/test/core_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
# LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
# LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down Expand Up @@ -84,9 +96,21 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
# LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
# LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down Expand Up @@ -157,9 +181,21 @@ end
using LineSearches: LineSearches
using BenchmarkTools: @ballocated
using StaticArrays: @SVector
using Zygote, Enzyme, ForwardDiff, FiniteDiff
using Zygote, ForwardDiff, FiniteDiff

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Conditionally import Enzyme only if not on Julia prerelease
include("test_utilities.jl")
if !is_julia_prerelease()
using Enzyme
end

@testset for ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff(), AutoEnzyme())
# Filter autodiff backends based on Julia version
autodiff_backends = [AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()]
if !is_julia_prerelease()
push!(autodiff_backends, AutoEnzyme())
end

Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@testset for ad in autodiff_backends
@testset "$(nameof(typeof(linesearch)))" for linesearch in (
# LineSearchesJL(; method = LineSearches.Static(), autodiff = ad),
# LineSearchesJL(; method = LineSearches.BackTracking(), autodiff = ad),
Expand Down
30 changes: 30 additions & 0 deletions lib/NonlinearSolveQuasiNewton/test/test_utilities.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Test utilities for NonlinearSolveQuasiNewton

"""
is_julia_prerelease()

Check if the current Julia version is a prerelease version (e.g., DEV, alpha, beta, rc).
"""
function is_julia_prerelease()
version_string = string(VERSION)
# Check for DEV versions (e.g., "1.12.0-DEV.1234")
contains(version_string, "DEV") && return true
# Check for alpha/beta/rc versions
contains(version_string, "alpha") && return true
contains(version_string, "beta") && return true
contains(version_string, "rc") && return true
return false
end

"""
filter_autodiff_backends(backends)

Filter out AutoEnzyme from the list of autodiff backends if running on Julia prerelease.
"""
function filter_autodiff_backends(backends)
if is_julia_prerelease()
return filter(ad -> !isa(ad, AutoEnzyme), backends)
else
return backends
end
end
Loading
Loading