Skip to content

Commit b79f2e1

Browse files
Merge pull request #238 from ArnoStrouwen/format
reapply formatter
2 parents 4429a1c + dbbb3c6 commit b79f2e1

File tree

17 files changed

+182
-154
lines changed

17 files changed

+182
-154
lines changed

.JuliaFormatter.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
style = "sciml"
2-
format_markdown = true
2+
format_markdown = true
3+
format_docstrings = true

docs/pages.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ pages = [
88
# "tutorials/nonlin.md",
99
# "tutorials/ode.md",
1010
# "tutorials/lux.md",
11-
],
11+
]
1212
]

docs/src/tutorials/fftw.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ n = 256
1515
L = 2π
1616
1717
dx = L / n
18-
x = range(start=-L/2, stop=L/2-dx, length=n) |> Array
19-
u = @. sin(5x)cos(7x);
18+
x = range(start = -L / 2, stop = L / 2 - dx, length = n) |> Array
19+
u = @. sin(5x)cos(7x);
2020
du = @. 5cos(5x)cos(7x) - 7sin(5x)sin(7x);
2121
22-
k = rfftfreq(n, 2π*n/L) |> Array
22+
k = rfftfreq(n, 2π * n / L) |> Array
2323
m = length(k)
2424
P = plan_rfft(x)
2525
@@ -29,23 +29,19 @@ bwd(u, p, t) = P \ u
2929
fwd(du, u, p, t) = mul!(du, P, u)
3030
bwd(du, u, p, t) = ldiv!(du, P, u)
3131
32-
F = FunctionOperator(fwd, x, im*k;
33-
T=ComplexF64,
34-
35-
op_adjoint = bwd,
36-
op_inverse = bwd,
37-
op_adjoint_inverse = fwd,
38-
39-
islinear=true,
40-
)
32+
F = FunctionOperator(fwd, x, im * k;
33+
T = ComplexF64, op_adjoint = bwd,
34+
op_inverse = bwd,
35+
op_adjoint_inverse = fwd, islinear = true
36+
)
4137
4238
ik = im * DiagonalOperator(k)
4339
Dx = F \ ik * F
4440
4541
Dx = cache_operator(Dx, x)
4642
47-
@show ≈(Dx * u, du; atol=1e-8)
48-
@show ≈(mul!(copy(u), Dx, u), du; atol=1e-8)
43+
@show ≈(Dx * u, du; atol = 1e-8)
44+
@show ≈(mul!(copy(u), Dx, u), du; atol = 1e-8)
4945
```
5046

5147
## Explanation
@@ -60,14 +56,13 @@ FFT wrapper.
6056
using SciMLOperators
6157
using LinearAlgebra, FFTW
6258
63-
L = 2π
64-
n = 256
59+
L = 2π
60+
n = 256
6561
dx = L / n
66-
x = range(start=-L/2, stop=L/2-dx, length=n) |> Array
62+
x = range(start = -L / 2, stop = L / 2 - dx, length = n) |> Array
6763
68-
u = @. sin(5x)cos(7x);
64+
u = @. sin(5x)cos(7x);
6965
du = @. 5cos(5x)cos(7x) - 7sin(5x)sin(7x);
70-
7166
```
7267

7368
Now, we define the Fourier transform. Since our input is purely Real, we use the real
@@ -77,8 +72,8 @@ and `LinearAlgebra.mul!(xhat, transform, x)`. We also get `k`, the frequency mo
7772
our finite grid, via the function `rfftfreq`.
7873

7974
```@example fft_explanation
80-
k = rfftfreq(n, 2π*n/L) |> Array
81-
m = length(k)
75+
k = rfftfreq(n, 2π * n / L) |> Array
76+
m = length(k)
8277
P = plan_rfft(x)
8378
```
8479

@@ -93,15 +88,11 @@ bwd(u, p, t) = P \ u
9388
9489
fwd(du, u, p, t) = mul!(du, P, u)
9590
bwd(du, u, p, t) = ldiv!(du, P, u)
96-
F = FunctionOperator(fwd, x, im*k;
97-
T=ComplexF64,
98-
99-
op_adjoint = bwd,
100-
op_inverse = bwd,
101-
op_adjoint_inverse = fwd,
102-
103-
islinear=true,
104-
)
91+
F = FunctionOperator(fwd, x, im * k;
92+
T = ComplexF64, op_adjoint = bwd,
93+
op_inverse = bwd,
94+
op_adjoint_inverse = fwd, islinear = true
95+
)
10596
```
10697

10798
After wrapping the FFT with `FunctionOperator`, we are ready to compose it with other
@@ -115,6 +106,6 @@ Dx = F \ ik * F
115106
116107
Dx = cache_operator(Dx, x)
117108
118-
@show ≈(Dx * u, du; atol=1e-8)
119-
@show ≈(mul!(copy(u), Dx, u), du; atol=1e-8)
109+
@show ≈(Dx * u, du; atol = 1e-8)
110+
@show ≈(mul!(copy(u), Dx, u), du; atol = 1e-8)
120111
```

src/SciMLOperators.jl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,30 @@ include("func.jl")
7878
include("tensor.jl")
7979

8080
export
81-
IdentityOperator,
82-
NullOperator,
83-
ScalarOperator,
84-
MatrixOperator,
85-
DiagonalOperator,
86-
InvertibleOperator,
87-
AffineOperator,
88-
AddVector,
89-
FunctionOperator,
90-
TensorProductOperator
81+
IdentityOperator,
82+
NullOperator,
83+
ScalarOperator,
84+
MatrixOperator,
85+
DiagonalOperator,
86+
InvertibleOperator,
87+
AffineOperator,
88+
AddVector,
89+
FunctionOperator,
90+
TensorProductOperator
9191

9292
export update_coefficients!,
93-
update_coefficients, isconstant,
94-
iscached,
95-
cache_operator, issquare,
96-
islinear,
97-
concretize,
98-
isconvertible, has_adjoint,
99-
has_expmv,
100-
has_expmv!,
101-
has_exp,
102-
has_mul,
103-
has_mul!,
104-
has_ldiv,
105-
has_ldiv!
93+
update_coefficients, isconstant,
94+
iscached,
95+
cache_operator, issquare,
96+
islinear,
97+
concretize,
98+
isconvertible, has_adjoint,
99+
has_expmv,
100+
has_expmv!,
101+
has_exp,
102+
has_mul,
103+
has_mul!,
104+
has_ldiv,
105+
has_ldiv!
106106

107107
end # module

src/basic.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ $TYPEDEF
180180
"""
181181
struct ScaledOperator{T,
182182
λType,
183-
LType,
183+
LType
184184
} <: AbstractSciMLOperator{T}
185185
λ::λType
186186
L::LType
@@ -194,7 +194,8 @@ end
194194

195195
# constructors
196196
for T in SCALINGNUMBERTYPES[2:end]
197-
@eval ScaledOperator::$T, L::AbstractSciMLOperator) = ScaledOperator(ScalarOperator(λ),
197+
@eval ScaledOperator::$T, L::AbstractSciMLOperator) = ScaledOperator(
198+
ScalarOperator(λ),
198199
L)
199200
end
200201

@@ -312,7 +313,7 @@ Lazy operator addition
312313
(A1 + A2 + A3...)u = A1*u + A2*u + A3*u ....
313314
"""
314315
struct AddedOperator{T,
315-
O <: Tuple{Vararg{AbstractSciMLOperator}},
316+
O <: Tuple{Vararg{AbstractSciMLOperator}}
316317
} <: AbstractSciMLOperator{T}
317318
ops::O
318319

@@ -491,9 +492,11 @@ end
491492
# constructors
492493
for op in (:*, :)
493494
@eval Base.$op(ops::AbstractSciMLOperator...) = reduce($op, ops)
494-
@eval Base.$op(A::AbstractSciMLOperator, B::AbstractSciMLOperator) = ComposedOperator(A,
495+
@eval Base.$op(A::AbstractSciMLOperator, B::AbstractSciMLOperator) = ComposedOperator(
496+
A,
495497
B)
496-
@eval Base.$op(A::ComposedOperator, B::AbstractSciMLOperator) = ComposedOperator(A.ops...,
498+
@eval Base.$op(A::ComposedOperator, B::AbstractSciMLOperator) = ComposedOperator(
499+
A.ops...,
497500
B)
498501
@eval Base.$op(A::AbstractSciMLOperator, B::ComposedOperator) = ComposedOperator(A,
499502
B.ops...)
@@ -553,7 +556,7 @@ Base.size(L::ComposedOperator) = (size(first(L.ops), 1), size(last(L.ops), 2))
553556
for op in (:adjoint,
554557
:transpose)
555558
@eval Base.$op(L::ComposedOperator) = ComposedOperator($op.(reverse(L.ops))...;
556-
cache = iscached(L) ? reverse(L.cache) : nothing,)
559+
cache = iscached(L) ? reverse(L.cache) : nothing)
557560
end
558561
Base.conj(L::ComposedOperator) = ComposedOperator(conj.(L.ops); cache = L.cache)
559562
function Base.resize!(L::ComposedOperator, n::Integer)
@@ -596,7 +599,8 @@ for fact in (:lu, :lu!,
596599
:bunchkaufman, :bunchkaufman!,
597600
:lq, :lq!,
598601
:svd, :svd!)
599-
@eval LinearAlgebra.$fact(L::ComposedOperator, args...) = prod(op -> $fact(op, args...),
602+
@eval LinearAlgebra.$fact(L::ComposedOperator, args...) = prod(
603+
op -> $fact(op, args...),
600604
reverse(L.ops))
601605
end
602606

src/batch.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct BatchedDiagonalOperator{T, D, F, F!} <: AbstractSciMLOperator{T}
1818
eltype(diag),
1919
typeof(diag),
2020
typeof(update_func),
21-
typeof(update_func!),
21+
typeof(update_func!)
2222
}(diag,
2323
update_func,
2424
update_func!)
@@ -63,7 +63,7 @@ function Base.conj(L::BatchedDiagonalOperator) # TODO - test this thoroughly
6363
DiagonalOperator(conj(L.diag);
6464
update_func = update_func,
6565
update_func! = update_func!,
66-
accepted_kwargs = NoKwargFilter(),)
66+
accepted_kwargs = NoKwargFilter())
6767
end
6868

6969
function Base.convert(::Type{AbstractMatrix}, L::BatchedDiagonalOperator)

0 commit comments

Comments
 (0)