Skip to content

Commit bdddafb

Browse files
authored
chore: apply JuliaFormatter v2 (#784)
1 parent e383ca2 commit bdddafb

File tree

7 files changed

+22
-34
lines changed

7 files changed

+22
-34
lines changed

DifferentiationInterface/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ FiniteDifferences = "0.12.31"
6565
ForwardDiff = "0.10.36,1"
6666
GPUArraysCore = "0.2"
6767
GTPSA = "1.4.0"
68-
JuliaFormatter = "1"
68+
JuliaFormatter = "1,2"
6969
LinearAlgebra = "<0.0.1,1"
7070
Mooncake = "0.4.88"
7171
PolyesterForwardDiff = "0.1.2"

DifferentiationInterface/ext/DifferentiationInterfaceEnzymeExt/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ to_val(::DI.BatchSizeSettings{B}) where {B} = Val(B)
99
## Annotations
1010

1111
@inline function get_f_and_df(
12-
f::F, backend::AutoEnzyme{M,Nothing}, mode::Mode, ::Val{B}=Val(1)
12+
f::F, backend::AutoEnzyme{M,Nothing}, mode::Mode, (::Val{B})=Val(1)
1313
) where {F,M,B}
1414
return f
1515
end
1616

1717
@inline function get_f_and_df(
18-
f::F, backend::AutoEnzyme{M,<:Const}, mode::Mode, ::Val{B}=Val(1)
18+
f::F, backend::AutoEnzyme{M,<:Const}, mode::Mode, (::Val{B})=Val(1)
1919
) where {F,M,B}
2020
return Const(f)
2121
end
@@ -34,7 +34,7 @@ end
3434
},
3535
},
3636
mode::Mode,
37-
::Val{B}=Val(1),
37+
(::Val{B})=Val(1),
3838
) where {F,M,B}
3939
# TODO: needs more sophistication for mixed activities
4040
if B == 1

DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/onearg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function DI.pushforward(
4646
DI.check_prep(f, prep, backend, x, tx, contexts...)
4747
fc = DI.fix_tail(f, map(DI.unwrap, contexts)...)
4848
ty = map(tx) do dx
49-
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
49+
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
5050
yt = fc(prep.xt)
5151
if yt isa Number
5252
return yt[1]
@@ -71,7 +71,7 @@ function DI.pushforward!(
7171
fc = DI.fix_tail(f, map(DI.unwrap, contexts)...)
7272
for b in eachindex(tx, ty)
7373
dx, dy = tx[b], ty[b]
74-
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
74+
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
7575
yt = fc(prep.xt)
7676
map!(t -> t[1], dy, yt)
7777
end

DifferentiationInterface/ext/DifferentiationInterfaceGTPSAExt/twoarg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function DI.pushforward(
5656
DI.check_prep(f!, y, prep, backend, x, tx, contexts...)
5757
fc! = DI.fix_tail(f!, map(DI.unwrap, contexts)...)
5858
ty = map(tx) do dx
59-
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
59+
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
6060
fc!(prep.yt, prep.xt)
6161
dy = map(t -> t[1], prep.yt)
6262
return dy
@@ -79,7 +79,7 @@ function DI.pushforward!(
7979
fc! = DI.fix_tail(f!, map(DI.unwrap, contexts)...)
8080
for b in eachindex(tx, ty)
8181
dx, dy = tx[b], ty[b]
82-
foreach((t, xi, dxi) -> (t[0] = xi; t[1] = dxi), prep.xt, x, dx)
82+
foreach((t, xi, dxi) -> (t[0]=xi; t[1]=dxi), prep.xt, x, dx)
8383
fc!(prep.yt, prep.xt)
8484
map!(t -> t[1], dy, prep.yt)
8585
end

DifferentiationInterfaceTest/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ForwardDiff = "0.10.36,1"
5252
Functors = "0.4, 0.5"
5353
JET = "0.4 - 0.8, 0.9"
5454
JLArrays = "0.1, 0.2"
55-
JuliaFormatter = "1"
55+
JuliaFormatter = "1,2"
5656
LinearAlgebra = "<0.0.1,1"
5757
Lux = "1.1.0"
5858
LuxTestUtils = "1.3.1"

DifferentiationInterfaceTest/ext/DifferentiationInterfaceTestComponentArraysExt/DifferentiationInterfaceTestComponentArraysExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function comp_to_num(x::ComponentVector)::Number
1010
return sum(sin.(x.a)) + sum(cos.(x.b))
1111
end
1212

13-
comp_to_num_gradient(x) = ComponentVector(; a=cos.(x.a), b=-sin.(x.b))
13+
comp_to_num_gradient(x) = ComponentVector(; a=cos.(x.a), b=(-sin.(x.b)))
1414

1515
function comp_to_num_pushforward(x, dx)
1616
g = comp_to_num_gradient(x)

DifferentiationInterfaceTest/src/tests/correctness_eval.jl

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ for op in ALL_OPS
5656
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
5757
local prepstrict
5858
preptup_cands_val, preptup_cands_noval = map(1:2) do _
59-
new_smaller =
60-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
59+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
6160
deepcopy(scen)
6261
else
6362
deepcopy(smaller)
@@ -124,8 +123,7 @@ for op in ALL_OPS
124123
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
125124
local prepstrict
126125
preptup_cands_val, preptup_cands_noval = map(1:2) do _
127-
new_smaller =
128-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
126+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
129127
deepcopy(scen)
130128
else
131129
deepcopy(smaller)
@@ -208,8 +206,7 @@ for op in ALL_OPS
208206
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
209207
local prepstrict
210208
preptup_cands_val, preptup_cands_noval = map(1:2) do _
211-
new_smaller =
212-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
209+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
213210
deepcopy(scen)
214211
else
215212
deepcopy(smaller)
@@ -286,8 +283,7 @@ for op in ALL_OPS
286283
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
287284
local prepstrict
288285
preptup_cands_val, preptup_cands_noval = map(1:2) do _
289-
new_smaller =
290-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
286+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
291287
deepcopy(scen)
292288
else
293289
deepcopy(smaller)
@@ -375,8 +371,7 @@ for op in ALL_OPS
375371
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
376372
local prepstrict
377373
preptup_cands_val, preptup_cands_noval = map(1:2) do _
378-
new_smaller =
379-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
374+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
380375
deepcopy(scen)
381376
else
382377
deepcopy(smaller)
@@ -445,8 +440,7 @@ for op in ALL_OPS
445440
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
446441
local prepstrict
447442
preptup_cands_val, preptup_cands_noval = map(1:2) do _
448-
new_smaller =
449-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
443+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
450444
deepcopy(scen)
451445
else
452446
deepcopy(smaller)
@@ -532,8 +526,7 @@ for op in ALL_OPS
532526
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
533527
local prepstrict
534528
preptup_cands_val, preptup_cands_noval = map(1:2) do _
535-
new_smaller =
536-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
529+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
537530
deepcopy(scen)
538531
else
539532
deepcopy(smaller)
@@ -599,8 +592,7 @@ for op in ALL_OPS
599592
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
600593
local prepstrict
601594
preptup_cands_val, preptup_cands_noval = map(1:2) do _
602-
new_smaller =
603-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
595+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
604596
deepcopy(scen)
605597
else
606598
deepcopy(smaller)
@@ -682,8 +674,7 @@ for op in ALL_OPS
682674
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
683675
local prepstrict
684676
preptup_cands_val, preptup_cands_noval = map(1:2) do _
685-
new_smaller =
686-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
677+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
687678
deepcopy(scen)
688679
else
689680
deepcopy(smaller)
@@ -765,8 +756,7 @@ for op in ALL_OPS
765756
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
766757
local prepstrict
767758
preptup_cands_val, preptup_cands_noval = map(1:2) do _
768-
new_smaller =
769-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
759+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
770760
deepcopy(scen)
771761
else
772762
deepcopy(smaller)
@@ -867,8 +857,7 @@ for op in ALL_OPS
867857
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
868858
local prepstrict
869859
preptup_cands_val, preptup_cands_noval = map(1:2) do _
870-
new_smaller =
871-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
860+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
872861
deepcopy(scen)
873862
else
874863
deepcopy(smaller)
@@ -934,8 +923,7 @@ for op in ALL_OPS
934923
contextsrand = rewrap(map(myrandom unwrap, contexts)...)
935924
local prepstrict
936925
preptup_cands_val, preptup_cands_noval = map(1:2) do _
937-
new_smaller =
938-
if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
926+
new_smaller = if isnothing(smaller) || adapt_batchsize(ba, smaller) != ba
939927
deepcopy(scen)
940928
else
941929
deepcopy(smaller)

0 commit comments

Comments
 (0)