diff --git a/DifferentiationInterface/Project.toml b/DifferentiationInterface/Project.toml index 75fbf7634..5f2a9e96a 100644 --- a/DifferentiationInterface/Project.toml +++ b/DifferentiationInterface/Project.toml @@ -65,7 +65,7 @@ FiniteDifferences = "0.12.31" ForwardDiff = "0.10.36,1" GPUArraysCore = "0.2" GTPSA = "1.4.0" -JuliaFormatter = "1" +JuliaFormatter = "1,2" LinearAlgebra = "<0.0.1,1" Mooncake = "0.4.88" PolyesterForwardDiff = "0.1.2" diff --git a/DifferentiationInterface/ext/DifferentiationInterfaceEnzymeExt/utils.jl b/DifferentiationInterface/ext/DifferentiationInterfaceEnzymeExt/utils.jl index 64a27e2e5..3c3180c79 100644 --- a/DifferentiationInterface/ext/DifferentiationInterfaceEnzymeExt/utils.jl +++ b/DifferentiationInterface/ext/DifferentiationInterfaceEnzymeExt/utils.jl @@ -9,13 +9,13 @@ to_val(::DI.BatchSizeSettings{B}) where {B} = Val(B) ## Annotations @inline function get_f_and_df( - f::F, backend::AutoEnzyme{M,Nothing}, mode::Mode, ::Val{B}=Val(1) + f::F, backend::AutoEnzyme{M,Nothing}, mode::Mode, (::Val{B})=Val(1) ) where {F,M,B} return f end @inline function get_f_and_df( - f::F, backend::AutoEnzyme{M,<:Const}, mode::Mode, ::Val{B}=Val(1) + f::F, backend::AutoEnzyme{M,<:Const}, mode::Mode, (::Val{B})=Val(1) ) where {F,M,B} return Const(f) end @@ -34,7 +34,7 @@ end }, }, mode::Mode, - ::Val{B}=Val(1), + (::Val{B})=Val(1), ) where {F,M,B} # TODO: needs more sophistication for mixed activities if B == 1 diff --git a/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl b/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl index d20b31f4b..58baad569 100644 --- a/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl +++ b/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl @@ -46,7 +46,7 @@ function DI.pushforward( DI.check_prep(f, prep, backend, x, tx, contexts...) fc = DI.fix_tail(f, map(DI.unwrap, contexts)...) ty = map(tx) do dx - foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx) + foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx) yt = fc(prep.xt) if yt isa Number return yt[1] @@ -71,7 +71,7 @@ function DI.pushforward!( fc = DI.fix_tail(f, map(DI.unwrap, contexts)...) for b in eachindex(tx, ty) dx, dy = tx[b], ty[b] - foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx) + foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx) yt = fc(prep.xt) map!(t -> t[1], dy, yt) end diff --git a/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/twoarg.jl b/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/twoarg.jl index 9f8cc3cf3..5edbdf9e5 100644 --- a/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/twoarg.jl +++ b/DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/twoarg.jl @@ -56,7 +56,7 @@ function DI.pushforward( DI.check_prep(f!, y, prep, backend, x, tx, contexts...) fc! = DI.fix_tail(f!, map(DI.unwrap, contexts)...) ty = map(tx) do dx - foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx) + foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx) fc!(prep.yt, prep.xt) dy = map(t -> t[1], prep.yt) return dy @@ -79,7 +79,7 @@ function DI.pushforward!( fc! = DI.fix_tail(f!, map(DI.unwrap, contexts)...) for b in eachindex(tx, ty) dx, dy = tx[b], ty[b] - foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx) + foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx) fc!(prep.yt, prep.xt) map!(t -> t[1], dy, prep.yt) end diff --git a/DifferentiationInterfaceTest/Project.toml b/DifferentiationInterfaceTest/Project.toml index a1aac1eca..26b7ccd4c 100644 --- a/DifferentiationInterfaceTest/Project.toml +++ b/DifferentiationInterfaceTest/Project.toml @@ -52,7 +52,7 @@ ForwardDiff = "0.10.36,1" Functors = "0.4, 0.5" JET = "0.4 - 0.8, 0.9" JLArrays = "0.1, 0.2" -JuliaFormatter = "1" +JuliaFormatter = "1,2" LinearAlgebra = "<0.0.1,1" Lux = "1.1.0" LuxTestUtils = "1.3.1" diff --git a/DifferentiationInterfaceTest/ext/DifferentiationInterfaceTestComponentArraysExt/DifferentiationInterfaceTestComponentArraysExt.jl b/DifferentiationInterfaceTest/ext/DifferentiationInterfaceTestComponentArraysExt/DifferentiationInterfaceTestComponentArraysExt.jl index 14aca7d77..ec5e37b27 100644 --- a/DifferentiationInterfaceTest/ext/DifferentiationInterfaceTestComponentArraysExt/DifferentiationInterfaceTestComponentArraysExt.jl +++ b/DifferentiationInterfaceTest/ext/DifferentiationInterfaceTestComponentArraysExt/DifferentiationInterfaceTestComponentArraysExt.jl @@ -10,7 +10,7 @@ function comp_to_num(x::ComponentVector)::Number return sum(sin.(x.a)) + sum(cos.(x.b)) end -comp_to_num_gradient(x) = ComponentVector(; a=cos.(x.a), b=-sin.(x.b)) +comp_to_num_gradient(x) = ComponentVector(; a=cos.(x.a), b=(-sin.(x.b))) function comp_to_num_pushforward(x, dx) g = comp_to_num_gradient(x) diff --git a/DifferentiationInterfaceTest/src/tests/correctness_eval.jl b/DifferentiationInterfaceTest/src/tests/correctness_eval.jl index 9ed8013f8..8b183059e 100644 --- a/DifferentiationInterfaceTest/src/tests/correctness_eval.jl +++ b/DifferentiationInterfaceTest/src/tests/correctness_eval.jl @@ -56,8 +56,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -124,8 +123,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -208,8 +206,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -286,8 +283,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -375,8 +371,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -445,8 +440,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -532,8 +526,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -599,8 +592,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -682,8 +674,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -765,8 +756,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -867,8 +857,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller) @@ -934,8 +923,7 @@ for op in ALL_OPS contextsrand = rewrap(map(myrandom ∘ unwrap, contexts)...) local prepstrict preptup_cands_val, preptup_cands_noval = map(1:2) do _ - new_smaller = - if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba + new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba deepcopy(scen) else deepcopy(smaller)