From f37da0a3ba6428afab8583491fa7eba47b08150c Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Wed, 30 Oct 2024 15:25:03 -0400 Subject: [PATCH] chore: run formatter --- .../src/NonlinearSolveBase.jl | 21 +++++++++++-------- lib/NonlinearSolveBase/src/utils.jl | 2 +- .../src/NonlinearSolveFirstOrder.jl | 16 +++++++------- .../src/NonlinearSolveQuasiNewton.jl | 7 ++++--- .../src/SciMLJacobianOperators.jl | 2 +- src/NonlinearSolve.jl | 18 ++++++++++++---- 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/lib/NonlinearSolveBase/src/NonlinearSolveBase.jl b/lib/NonlinearSolveBase/src/NonlinearSolveBase.jl index e9fd61dff..7cb1cffaf 100644 --- a/lib/NonlinearSolveBase/src/NonlinearSolveBase.jl +++ b/lib/NonlinearSolveBase/src/NonlinearSolveBase.jl @@ -1,21 +1,21 @@ module NonlinearSolveBase +using Compat: @compat +using ConcreteStructs: @concrete +using FastClosures: @closure +using Preferences: @load_preference + using ADTypes: ADTypes, AbstractADType, AutoSparse, NoSparsityDetector, KnownJacobianSparsityDetector using Adapt: WrappedArray using ArrayInterface: ArrayInterface -using CommonSolve: CommonSolve, init -using Compat: @compat -using ConcreteStructs: @concrete using DifferentiationInterface: DifferentiationInterface, Constant +using StaticArraysCore: StaticArray, SMatrix, SArray, MArray + +using CommonSolve: CommonSolve, init using EnzymeCore: EnzymeCore -using FastClosures: @closure using FunctionProperties: hasbranching -using LinearAlgebra: LinearAlgebra, Diagonal, norm, ldiv!, diagind -using Markdown: @doc_str using MaybeInplace: @bb -using Preferences: @load_preference -using Printf: @printf using RecursiveArrayTools: AbstractVectorOfArray, ArrayPartition using SciMLBase: SciMLBase, ReturnCode, AbstractODEIntegrator, AbstractNonlinearProblem, AbstractNonlinearAlgorithm, AbstractNonlinearFunction, @@ -23,9 +23,12 @@ using SciMLBase: SciMLBase, ReturnCode, AbstractODEIntegrator, AbstractNonlinear NonlinearFunction, NullParameters, NLStats, LinearProblem using SciMLJacobianOperators: JacobianOperator, StatefulJacobianOperator using SciMLOperators: AbstractSciMLOperator, IdentityOperator -using StaticArraysCore: StaticArray, SMatrix, SArray, MArray using SymbolicIndexingInterface: SymbolicIndexingInterface +using LinearAlgebra: LinearAlgebra, Diagonal, norm, ldiv!, diagind +using Markdown: @doc_str +using Printf: @printf + const DI = DifferentiationInterface const SII = SymbolicIndexingInterface diff --git a/lib/NonlinearSolveBase/src/utils.jl b/lib/NonlinearSolveBase/src/utils.jl index a1485debb..44c7e957a 100644 --- a/lib/NonlinearSolveBase/src/utils.jl +++ b/lib/NonlinearSolveBase/src/utils.jl @@ -94,7 +94,7 @@ restructure(::Number, x::Number) = x function restructure( y::T1, x::T2 ) where {T1 <: AbstractSciMLOperator, T2 <: AbstractSciMLOperator} - @assert size(y) == size(x) "cannot restructure operators. ensure their sizes match." + @assert size(y)==size(x) "cannot restructure operators. ensure their sizes match." return x end restructure(y, x) = ArrayInterface.restructure(y, x) diff --git a/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl b/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl index 15bdda938..789c13ab7 100644 --- a/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl +++ b/lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl @@ -1,16 +1,17 @@ module NonlinearSolveFirstOrder -using Reexport: @reexport +using ConcreteStructs: @concrete using PrecompileTools: @compile_workload, @setup_workload +using Reexport: @reexport +using Setfield: @set! using ADTypes: ADTypes using ArrayInterface: ArrayInterface +using LinearAlgebra: LinearAlgebra, Diagonal, dot +using StaticArraysCore: SArray + using CommonSolve: CommonSolve -using ConcreteStructs: @concrete using DiffEqBase: DiffEqBase # Needed for `init` / `solve` dispatches -using FiniteDiff: FiniteDiff # Default Finite Difference Method -using ForwardDiff: ForwardDiff # Default Forward Mode AD -using LinearAlgebra: LinearAlgebra, Diagonal, dot using LinearSolve: LinearSolve # Trigger Linear Solve extension in NonlinearSolveBase using MaybeInplace: @bb using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, @@ -23,8 +24,9 @@ using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, Dogleg using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode, NonlinearFunction using SciMLJacobianOperators: VecJacOperator, JacVecOperator, StatefulJacobianOperator -using Setfield: @set! -using StaticArraysCore: SArray + +using FiniteDiff: FiniteDiff # Default Finite Difference Method +using ForwardDiff: ForwardDiff # Default Forward Mode AD include("raphson.jl") include("gauss_newton.jl") diff --git a/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl b/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl index 597af0e15..3b63615e8 100644 --- a/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl +++ b/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl @@ -1,11 +1,13 @@ module NonlinearSolveQuasiNewton -using Reexport: @reexport +using ConcreteStructs: @concrete using PrecompileTools: @compile_workload, @setup_workload +using Reexport: @reexport using ArrayInterface: ArrayInterface +using StaticArraysCore: StaticArray, Size, MArray + using CommonSolve: CommonSolve -using ConcreteStructs: @concrete using DiffEqBase: DiffEqBase # Needed for `init` / `solve` dispatches using LinearAlgebra: LinearAlgebra, Diagonal, dot, diag using LinearSolve: LinearSolve # Trigger Linear Solve extension in NonlinearSolveBase @@ -20,7 +22,6 @@ using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, update_trace!, L2_NORM, NewtonDescent using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode using SciMLOperators: AbstractSciMLOperator -using StaticArraysCore: StaticArray, Size, MArray include("reset_conditions.jl") include("structure.jl") diff --git a/lib/SciMLJacobianOperators/src/SciMLJacobianOperators.jl b/lib/SciMLJacobianOperators/src/SciMLJacobianOperators.jl index e2a592e7d..a90c983b3 100644 --- a/lib/SciMLJacobianOperators/src/SciMLJacobianOperators.jl +++ b/lib/SciMLJacobianOperators/src/SciMLJacobianOperators.jl @@ -20,7 +20,7 @@ ArrayInterface.can_setindex(::AbstractJacobianOperator) = false function ArrayInterface.restructure( y::AbstractJacobianOperator, x::AbstractJacobianOperator ) - @assert size(y) == size(x) "cannot restructure operators. ensure their sizes match." + @assert size(y)==size(x) "cannot restructure operators. ensure their sizes match." return x end diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 4b7d73d8a..74dea2342 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -1,13 +1,14 @@ module NonlinearSolve +using ConcreteStructs: @concrete using Reexport: @reexport using PrecompileTools: @compile_workload, @setup_workload +using FastClosures: @closure +using ADTypes: ADTypes using ArrayInterface: ArrayInterface using CommonSolve: CommonSolve, solve, solve! -using ConcreteStructs: @concrete using DiffEqBase: DiffEqBase # Needed for `init` / `solve` dispatches -using FastClosures: @closure using LinearAlgebra: LinearAlgebra, norm using LineSearch: BackTracking using NonlinearSolveBase: NonlinearSolveBase, InternalAPI, AbstractNonlinearSolveAlgorithm, @@ -33,6 +34,15 @@ using ForwardDiff: ForwardDiff # Default Forward Mode AD using SparseArrays: SparseArrays using SparseMatrixColorings: SparseMatrixColorings +# Sub-Packages that are re-exported by NonlinearSolve +using BracketingNonlinearSolve: BracketingNonlinearSolve +using LineSearch: LineSearch +using LinearSolve: LinearSolve +using NonlinearSolveFirstOrder: NonlinearSolveFirstOrder +using NonlinearSolveQuasiNewton: NonlinearSolveQuasiNewton +using NonlinearSolveSpectralMethods: NonlinearSolveSpectralMethods +using SimpleNonlinearSolve: SimpleNonlinearSolve + const SII = SymbolicIndexingInterface include("helpers.jl") @@ -54,8 +64,8 @@ include("default.jl") # include("internal/forward_diff.jl") # we need to define after the algorithms @setup_workload begin - include(joinpath(@__DIR__, "..", "common", "nonlinear_problem_workloads.jl")) - include(joinpath(@__DIR__, "..", "common", "nlls_problem_workloads.jl")) + include("../common/nonlinear_problem_workloads.jl") + include("../common/nlls_problem_workloads.jl") @compile_workload begin @sync begin