Skip to content

Commit 840987d

Browse files
authored
Merge pull request #135 from IntegralEquations/runic-format
Switch to Runic.jl for formatting.
2 parents 16ffcef + 2023263 commit 840987d

63 files changed

Lines changed: 1702 additions & 1732 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.JuliaFormatter.toml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file contains a list of commits that should be ignored by git blame.
2+
# To use this file, run: git config blame.ignoreRevsFile .git-blame-ignore-revs
3+
# See: https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt
4+
5+
# Format all code with Runic.jl (replacing JuliaFormatter)
6+
8169f14c015561f0af30f67b3b8ab3697202b7e0

.github/workflows/format_check.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,13 @@ on:
88
pull_request:
99

1010
jobs:
11-
build:
12-
runs-on: ${{ matrix.os }}
13-
strategy:
14-
matrix:
15-
version:
16-
- '1'
17-
os:
18-
- ubuntu-latest
19-
arch:
20-
- x64
11+
runic:
12+
runs-on: ubuntu-latest
2113
steps:
14+
- uses: actions/checkout@v5
2215
- uses: julia-actions/setup-julia@latest
2316
with:
24-
version: ${{ matrix.version }}
25-
26-
- uses: actions/checkout@v5
27-
- name: Install JuliaFormatter and format
28-
run: |
29-
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
30-
julia -e 'using JuliaFormatter; format(".", verbose=true)'
31-
- name: Format check
32-
run: |
33-
julia -e '
34-
out = Cmd(`git diff --name-only`) |> read |> String
35-
if out == ""
36-
exit(0)
37-
else
38-
@error "Some files have not been formatted !!!"
39-
write(stdout, out)
40-
exit(1)
41-
end'
42-
43-
17+
version: '1'
18+
- uses: fredrikekre/runic-action@v1
19+
with:
20+
version: '1'

.github/workflows/format_pr.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v5
10-
- name: Install JuliaFormatter and format
10+
- uses: julia-actions/setup-julia@latest
11+
with:
12+
version: '1'
13+
- name: Install Runic and format
1114
run: |
12-
julia -e 'import Pkg; Pkg.add("JuliaFormatter")'
13-
julia -e 'using JuliaFormatter; format(".")'
15+
julia --project=@runic -e 'import Pkg; Pkg.add("Runic")'
16+
julia --project=@runic -e 'using Runic; Runic.main(["--inplace", "."])'
1417
1518
# https://github.com/marketplace/actions/create-pull-request
1619
# https://github.com/peter-evans/create-pull-request#reference-example
@@ -19,9 +22,9 @@ jobs:
1922
uses: peter-evans/create-pull-request@v7
2023
with:
2124
token: ${{ secrets.GITHUB_TOKEN }}
22-
commit-message: Format .jl files
23-
title: 'Automatic JuliaFormatter.jl run'
24-
branch: auto-juliaformatter-pr
25+
commit-message: Format .jl files with Runic
26+
title: 'Automatic Runic.jl run'
27+
branch: auto-runic-pr
2528
delete-branch: true
2629
labels: formatting, automated pr, no changelog
2730
- name: Check outputs

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/docs/src/pluto-examples/*.md
1212
/sandbox/*
1313
/talks/*
14+
/test/vtk_output/*
1415

1516
.markdownlint.json
1617
Inti.code-workspace

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Build Status](https://github.com/IntegralEquations/Inti.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/IntegralEquations/Inti.jl/actions/workflows/CI.yml?query=branch%3Amain)
66
[![codecov](https://codecov.io/gh/IntegralEquations/Inti.jl/graph/badge.svg?token=2VF6BR8LA0)](https://codecov.io/gh/IntegralEquations/Inti.jl)
77
[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://inti.zulipchat.com)
8+
[![Runic](https://img.shields.io/badge/code%20style-runic-hotpink.svg)](https://github.com/fredrikekre/Runic.jl)
89
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
910

1011
A package for efficient and high-order discretization and application of

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Gmsh = "705231aa-382f-11e9-3f0c-b7cb4346fdeb"
1010
HMatrices = "8646bddf-ab1c-4fa7-9c51-ba187d647618"
1111
Inti = "fb74042b-437e-4c5b-88cf-d4e2beb394d5"
1212
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
13-
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
1413
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
1514
LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e"
1615
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
1716
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
1817
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
1918
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
19+
Runic = "62bfec6d-59d7-401d-8490-b29ee721c001"
2020
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2121
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
2222
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"

docs/make.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Documenter
33
using DocumenterCitations
44
using DocumenterInterLinks
55
using Pluto
6-
using JuliaFormatter
6+
using Runic
77
# packages needed for extensions
88
using Gmsh
99
using HMatrices
@@ -19,13 +19,13 @@ ON_CI && (draft = false) # always full build on CI
1919

2020
# from https://github.com/fonsp/Pluto.jl/pull/2471
2121
function generate_plaintext(
22-
notebook,
23-
strmacrotrim::Union{String,Nothing} = nothing;
24-
header::Function = _ -> nothing,
25-
footer::Function = _ -> nothing,
26-
textcomment::Function = identity,
27-
codewrapper::Function,
28-
)
22+
notebook,
23+
strmacrotrim::Union{String, Nothing} = nothing;
24+
header::Function = _ -> nothing,
25+
footer::Function = _ -> nothing,
26+
textcomment::Function = identity,
27+
codewrapper::Function,
28+
)
2929
cell_strings = String[]
3030
header_content = header(notebook)
3131
isnothing(header_content) || push!(cell_strings, header_content)
@@ -64,17 +64,17 @@ function generate_md(input; output = replace(input, r"\.jl$" => ".md"))
6464
notebook = Pluto.load_notebook(input)
6565
header =
6666
_ ->
67-
"[![Pluto notebook](https://img.shields.io/badge/download-Pluto_notebook-blue)]($fname)"
67+
"[![Pluto notebook](https://img.shields.io/badge/download-Pluto_notebook-blue)]($fname)"
6868

6969
function codewrapper(cell, _)
7070
# 1. Strips begin/end block
71-
# 2. Reformats code using JuliaFormatter
71+
# 2. Reformats code using Runic
7272
# 3. Wraps all code in same ```@example``` block for documenter
7373
code = strip(cell.code)
7474
if startswith(code, "begin") && endswith(code, "end")
75-
code = strip(code[6:end-4]) # Remove "begin" and "end" and strip spaces
76-
# reformat code using JuliaFormatter
77-
code = format_text(String(code))
75+
code = strip(code[6:(end - 4)]) # Remove "begin" and "end" and strip spaces
76+
# reformat code using Runic
77+
code = Runic.format_string(String(code))
7878
end
7979
return if cell.code_folded
8080
string("```@setup $fname\n", code, "\n```")
@@ -117,7 +117,7 @@ notebooks = [
117117
"Poisson problem" => "poisson.jl",
118118
]
119119

120-
notebook_examples = Pair{String,String}[]
120+
notebook_examples = Pair{String, String}[]
121121
for notebook in notebooks
122122
title, fname = notebook
123123
file_in = joinpath(@__DIR__, "src", "pluto-examples", fname)

docs/src/examples/helmholtz_scattering.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ using LinearMaps
113113

114114
# and setup some of the (global) problem parameters:
115115

116-
k = 4π
117-
λ = 2π / k
116+
k = 4π
117+
λ = 2π / k
118118
qorder = 4 # quadrature order
119119
gorder = 2 # order of geometrical approximation
120120
nothing #hide
@@ -127,7 +127,7 @@ nothing #hide
127127
# function to mesh the circle:
128128

129129
function gmsh_circle(; name, meshsize, order = 1, radius = 1, center = (0, 0))
130-
try
130+
return try
131131
gmsh.initialize()
132132
gmsh.model.add("circle-mesh")
133133
gmsh.option.setNumber("Mesh.MeshSizeMax", meshsize)
@@ -190,7 +190,7 @@ nothing #hide
190190
# integrating the function `x->1` over `Q` gives an approximation to the
191191
# perimeter:
192192

193-
@assert abs(Inti.integrate(x -> 1, Q) - 2π) < 1e-5 #hide
193+
@assert abs(Inti.integrate(x -> 1, Q) - 2π) < 1.0e-5 #hide
194194
abs(Inti.integrate(x -> 1, Q) - 2π)
195195

196196
# With the [`Quadrature`](@ref Inti.Quadrature) constructed, we now can define
@@ -260,7 +260,7 @@ nothing #hide
260260
# potentials, and then combine them as follows:
261261

262262
𝒮, 𝒟 = Inti.single_double_layer_potential(; op, source = Q)
263-
uₛ = x -> 𝒟[σ](x) - im * k * 𝒮[σ](x)
263+
uₛ = x -> 𝒟[σ](x) - im * k * 𝒮[σ](x)
264264
nothing #hide
265265

266266
# The variable `uₛ` is an anonymous/lambda function representing the approximate
@@ -277,9 +277,9 @@ function circle_helmholtz_soundsoft(pt; radius = 1, k, θin)
277277
u = 0.0
278278
r < radius && return u
279279
c(n) = -exp(im * n */ 2 - θin)) * besselj(n, k * radius) / besselh(n, k * radius)
280-
u = c(0) * besselh(0, k * r)
281-
n = 1
282-
while (abs(c(n)) > 1e-12)
280+
u = c(0) * besselh(0, k * r)
281+
n = 1
282+
while (abs(c(n)) > 1.0e-12)
283283
u +=
284284
c(n) * besselh(n, k * r) * exp(im * n * θ) +
285285
c(-n) * besselh(-n, k * r) * exp(-im * n * θ)
@@ -297,7 +297,7 @@ er = maximum(0:0.01:2π) do θ
297297
x = (R * cos(θ), R * sin(θ))
298298
return abs(uₛ(x) - uₑ(x))
299299
end
300-
@assert er < 1e-3 #hide
300+
@assert er < 1.0e-3 #hide
301301
@info "maximum error = $er"
302302

303303
# As we can see, the error is quite small! Let's use `Makie` to visualize the solution in this
@@ -450,15 +450,15 @@ S, D = Inti.single_double_layer(;
450450
op,
451451
target = Q,
452452
source = Q,
453-
compression = (method = :hmatrix, tol = 1e-4),
453+
compression = (method = :hmatrix, tol = 1.0e-4),
454454
correction = (method = :dim,),
455455
)
456456
nothing #hide
457457

458458
# Here is how much memory it would take to store the dense representation of
459459
# these matrices:
460460

461-
mem = 2 * length(S) * 16 / 1e9 # 16 bytes per complex number, 1e9 bytes per GB, two matrices
461+
mem = 2 * length(S) * 16 / 1.0e9 # 16 bytes per complex number, 1e9 bytes per GB, two matrices
462462
println("memory required to store S and D: $(mem) GB")
463463

464464
# Even for this simple example, the dense representation of the integral
@@ -492,7 +492,7 @@ rhs = map(Q) do q
492492
return -uᵢ(x)
493493
end
494494
σ, hist =
495-
gmres(L, rhs; log = true, abstol = 1e-6, verbose = false, restart = 100, maxiter = 100)
495+
gmres(L, rhs; log = true, abstol = 1.0e-6, verbose = false, restart = 100, maxiter = 100)
496496
@show hist
497497

498498
# As before, let us represent the solution using `IntegralPotential`s:
@@ -517,7 +517,7 @@ function sphere_helmholtz_soundsoft(xobs; radius = 1, k = 1, θin = 0, ϕin = 0)
517517
r < radius && return u
518518
function c(l, m)
519519
return -4π * im^l * sphharmonic(l, -m, θin, ϕin) * sphbesselj(l, k * radius) /
520-
sphbesselh(l, k * radius)
520+
sphbesselh(l, k * radius)
521521
end
522522
l = 0
523523
for l in 0:60
@@ -538,7 +538,7 @@ er = maximum(1:100) do _
538538
x = 2 *
539539
return abs(uₛ(x) - uₑ(x))
540540
end
541-
@assert er < 1e-3 #hide
541+
@assert er < 1.0e-3 #hide
542542
@info "error with correction = $er"
543543

544544
# We see that, once again, the approximation is quite accurate. Let us now
@@ -553,7 +553,7 @@ S, D = Inti.single_double_layer(;
553553
op,
554554
target,
555555
source = Q,
556-
compression = (method = :hmatrix, tol = 1e-4),
556+
compression = (method = :hmatrix, tol = 1.0e-4),
557557
## correction for the nearfield (for visual purposes, set to `:none` to disable)
558558
correction = (method = :dim, maxdist = meshsize, target_location = :outside),
559559
)

docs/src/examples/lippmann_schwinger.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ nothing # hide
5252
using Gmsh # this will trigger the loading of Inti's Gmsh extension
5353

5454
function gmsh_disk(; name, meshsize, order = 1, center = (0, 0), paxis = (1, 1))
55-
try
55+
return try
5656
gmsh.initialize()
5757
gmsh.option.setNumber("General.Terminal", 0)
5858
gmsh.model.add("circle-mesh")
@@ -94,7 +94,7 @@ V_d2d = Inti.volume_potential(;
9494
op,
9595
target = Ωₕ_quad,
9696
source = Ωₕ_quad,
97-
compression = (method = :fmm, tol = 1e-7),
97+
compression = (method = :fmm, tol = 1.0e-7),
9898
correction = (method = :dim, interpolation_order),
9999
)
100100

@@ -121,13 +121,13 @@ L = I + k₁^2 * V_d2d * Lη
121121
# The unknown volumetric field $u$:
122122
using IterativeSolvers
123123
u, hist =
124-
gmres(L, rhs; log = true, abstol = 1e-7, verbose = false, restart = 200, maxiter = 200)
124+
gmres(L, rhs; log = true, abstol = 1.0e-7, verbose = false, restart = 200, maxiter = 200)
125125
@show hist
126126

127127
𝒱 = Inti.IntegralPotential(Inti.SingleLayerKernel(op), Ωₕ_quad)
128128

129129
# The representation formula gives the solution in $\R^2 \setminus \Omega$:
130-
= (x) -> uⁱ(x) - k₁^2 * 𝒱[refr_map_d.*u](x)
130+
= (x) -> uⁱ(x) - k₁^2 * 𝒱[refr_map_d .* u](x)
131131
nothing # hide
132132

133133
# To visualize the solution using Gmsh, let's query it at the triangle vertices in $\Omega$

0 commit comments

Comments
 (0)