Skip to content

Commit 080a971

Browse files
authored
Switch from JuliaFormatter to Runic, update JET (#188)
1 parent 4d3e988 commit 080a971

File tree

15 files changed

+109
-96
lines changed

15 files changed

+109
-96
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
version:
2323
- 'lts'
2424
- '1'
25-
# - 'pre'
25+
- 'pre'
2626
steps:
2727
- uses: actions/checkout@v6
2828
- uses: julia-actions/setup-julia@v2
@@ -74,3 +74,17 @@ jobs:
7474
using Documenter: doctest
7575
using ExplainableAI
7676
doctest(ExplainableAI)'
77+
78+
runic:
79+
name: Runic formatting
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v5
83+
# - uses: julia-actions/setup-julia@v2
84+
# with:
85+
# version: '1'
86+
# - uses: julia-actions/cache@v2
87+
- uses: fredrikekre/runic-action@v1
88+
with:
89+
version: '1'
90+

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ExplainableAI.jl
22

3+
## Version `v0.10.4-DEV`
4+
- ![Maintenance][badge-maintenance] Switch from JuliaFormatter to Runic, update JET ([#188])
5+
36
## Version `v0.10.3`
47
- ![Maintenance][badge-maintenance] Update dependencies
58

@@ -234,6 +237,7 @@ Performance improvements:
234237
[VisionHeatmaps]: https://julia-xai.github.io/XAIDocs/VisionHeatmaps/stable/
235238
[TextHeatmaps]: https://julia-xai.github.io/XAIDocs/TextHeatmaps/stable/
236239

240+
[#188]: https://github.com/Julia-XAI/ExplainableAI.jl/pull/188
237241
[#184]: https://github.com/Julia-XAI/ExplainableAI.jl/pull/184
238242
[#183]: https://github.com/Julia-XAI/ExplainableAI.jl/pull/183
239243
[#180]: https://github.com/Julia-XAI/ExplainableAI.jl/pull/180

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExplainableAI"
22
uuid = "4f1bc3e1-d60d-4ed0-9367-9bdff9846d3b"
33
authors = ["Adrian Hill <gh@adrianhill.de>"]
4-
version = "0.10.3"
4+
version = "0.10.4-DEV"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ___
66
| Documentation | [![][docs-stab-img]][docs-stab-url] [![][docs-dev-img]][docs-dev-url] [![][changelog-img]][changelog-url] |
77
| Build Status | [![][ci-img]][ci-url] [![][codecov-img]][codecov-url] |
88
| Testing | [![Aqua][aqua-img]][aqua-url] [![JET][jet-img]][jet-url] |
9-
| Code Style | [![Code Style: Blue][blue-img]][blue-url] [![ColPrac][colprac-img]][colprac-url] |
9+
| Code Style | [![Code Style: Runic](https://img.shields.io/badge/code_style-%E1%9A%B1%E1%9A%A2%E1%9A%BE%E1%9B%81%E1%9A%B2-black)](https://github.com/fredrikekre/Runic.jl) [![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac) |
1010
| Citation | [![][doi-img]][doi-url] |
1111

1212
Explainable AI in Julia.
@@ -182,12 +182,6 @@ Contributions are welcome!
182182
[jet-img]: https://img.shields.io/badge/%F0%9F%9B%A9%EF%B8%8F_tested_with-JET.jl-233f9a
183183
[jet-url]: https://github.com/aviatesk/JET.jl
184184

185-
186-
[blue-img]: https://img.shields.io/badge/code%20style-blue-4495d1.svg
187-
[blue-url]: https://github.com/invenia/BlueStyle
188-
[colprac-img]: https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet
189-
[colprac-url]: https://github.com/SciML/ColPrac
190-
191185
[docs-composites]: https://julia-xai.github.io/ExplainableAI.jl/stable/generated/lrp/composites/
192186
[docs-custom-rules]: https://julia-xai.github.io/ExplainableAI.jl/stable/generated/lrp/custom_rules/
193187

benchmark/bench_jogger.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ input = rand(T, input_size)
1111

1212
model = Chain(
1313
Chain(
14-
Conv((3, 3), 3 => 8, relu; pad=1),
15-
Conv((3, 3), 8 => 8, relu; pad=1),
14+
Conv((3, 3), 3 => 8, relu; pad = 1),
15+
Conv((3, 3), 8 => 8, relu; pad = 1),
1616
MaxPool((2, 2)),
17-
Conv((3, 3), 8 => 16, relu; pad=1),
18-
Conv((3, 3), 16 => 16, relu; pad=1),
17+
Conv((3, 3), 8 => 16, relu; pad = 1),
18+
Conv((3, 3), 16 => 16, relu; pad = 1),
1919
MaxPool((2, 2)),
2020
),
2121
Chain(
@@ -29,9 +29,9 @@ Flux.testmode!(model, true)
2929

3030
# Use one representative algorithm of each type
3131
METHODS = Dict(
32-
"Gradient" => Gradient,
33-
"InputTimesGradient" => InputTimesGradient,
34-
"SmoothGrad" => model -> SmoothGrad(model, 5),
32+
"Gradient" => Gradient,
33+
"InputTimesGradient" => InputTimesGradient,
34+
"SmoothGrad" => model -> SmoothGrad(model, 5),
3535
"IntegratedGradients" => model -> IntegratedGradients(model, 5),
3636
)
3737

docs/make.jl

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,23 @@ function convert_literate(dir_in, dir_out)
1313
if isdir(path)
1414
convert_literate(path, joinpath(dir_out, p))
1515
else # isfile
16-
Literate.markdown(path, dir_out; documenter=true) # Markdown for Documenter.jl
16+
Literate.markdown(path, dir_out; documenter = true) # Markdown for Documenter.jl
1717
Literate.notebook(path, dir_out) # .ipynb notebook
1818
Literate.script(path, dir_out) # .jl script
1919
end
2020
end
21+
return nothing
2122
end
2223
convert_literate(LITERATE_DIR, OUT_DIR)
2324

2425
makedocs(;
25-
modules=[XAIBase, ExplainableAI],
26-
authors="Adrian Hill",
27-
sitename="ExplainableAI.jl",
28-
format=Documenter.HTML(;
29-
prettyurls=get(ENV, "CI", "false") == "true",
30-
size_threshold=300_000,
31-
assets=String[],
26+
modules = [XAIBase, ExplainableAI],
27+
authors = "Adrian Hill",
28+
sitename = "ExplainableAI.jl",
29+
format = Documenter.HTML(;
30+
prettyurls = get(ENV, "CI", "false") == "true",
31+
size_threshold = 300_000,
32+
assets = String[],
3233
),
3334
#! format: off
3435
pages=[
@@ -40,13 +41,13 @@ makedocs(;
4041
"API Reference" => "api.md",
4142
],
4243
#! format: on
43-
linkcheck=true,
44-
linkcheck_ignore=[
44+
linkcheck = true,
45+
linkcheck_ignore = [
4546
r"https://link.springer.com/chapter/10.1007/978-3-030-28954-6_10",
4647
r"https://www.nature.com/articles/s42256-023-00711-8",
4748
],
48-
warnonly=[:missing_docs],
49-
checkdocs=:exports, # only check docstrings in API reference if they are exported
49+
warnonly = [:missing_docs],
50+
checkdocs = :exports, # only check docstrings in API reference if they are exported
5051
)
5152

52-
deploydocs(; repo="github.com/Julia-XAI/ExplainableAI.jl")
53+
deploydocs(; repo = "github.com/Julia-XAI/ExplainableAI.jl")

docs/src/literate/augmentations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ heatmap(input, analyzer)
7878
matrix_of_ones = ones(Float32, size(input))
7979

8080
analyzer = InterpolationAugmentation(Gradient(model), 50)
81-
expl = analyzer(input; input_ref=matrix_of_ones)
81+
expl = analyzer(input; input_ref = matrix_of_ones)
8282
heatmap(expl)
8383

8484
# Once again, `InterpolationAugmentation` can be combined with any analyzer type from the Julia-XAI ecosystem,

docs/src/literate/example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@ analyzer = InputTimesGradient(model)
123123
heatmap(input, analyzer)
124124

125125
# Using [VisionHeatmaps.jl](https://julia-xai.github.io/XAIDocs/VisionHeatmaps/stable/),
126-
# heatmaps can be heavily customized.
126+
# heatmaps can be heavily customized.
127127
# Check out the [heatmapping documentation](https://julia-xai.github.io/XAIDocs/VisionHeatmaps/stable/) for more information.

src/gradcam.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ GradCAM is compatible with a wide variety of CNN model-families.
1515
# References
1616
- $REF_SELVARAJU_GRADCAM
1717
"""
18-
struct GradCAM{F,A,B<:AbstractADType} <: AbstractXAIMethod
18+
struct GradCAM{F, A, B <: AbstractADType} <: AbstractXAIMethod
1919
feature_layers::F
2020
adaptation_layers::A
2121
backend::B
2222

2323
function GradCAM(
24-
feature_layers::F, adaptation_layers::A, backend::B=DEFAULT_AD_BACKEND
25-
) where {F,A,B<:AbstractADType}
26-
new{F,A,B}(feature_layers, adaptation_layers, backend)
24+
feature_layers::F, adaptation_layers::A, backend::B = DEFAULT_AD_BACKEND
25+
) where {F, A, B <: AbstractADType}
26+
return new{F, A, B}(feature_layers, adaptation_layers, backend)
2727
end
2828
end
2929
function call_analyzer(input, analyzer::GradCAM, ns::AbstractOutputSelector; kwargs...)
@@ -34,7 +34,7 @@ function call_analyzer(input, analyzer::GradCAM, ns::AbstractOutputSelector; kwa
3434
grad, output, output_indices = gradient_wrt_input(
3535
analyzer.adaptation_layers, A, ns, analyzer.backend
3636
)
37-
αᶜ = sum(grad; dims=(1, 2)) / feature_map_size
38-
Lᶜ = max.(sum(αᶜ .* A; dims=3), 0)
37+
αᶜ = sum(grad; dims = (1, 2)) / feature_map_size
38+
Lᶜ = max.(sum(αᶜ .* A; dims = 3), 0)
3939
return Explanation(Lᶜ, input, output, output_indices, :GradCAM, :cam, nothing)
4040
end

src/gradient.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ function forward_with_output_selection(model, input, selector::AbstractOutputSel
55
end
66

77
function gradient_wrt_input(
8-
model, input, output_selector::AbstractOutputSelector, backend::AbstractADType
9-
)
8+
model, input, output_selector::AbstractOutputSelector, backend::AbstractADType
9+
)
1010
output = model(input)
1111
return gradient_wrt_input(model, input, output, output_selector, backend)
1212
end
1313

1414
function gradient_wrt_input(
15-
model, input, output, output_selector::AbstractOutputSelector, backend::AbstractADType
16-
)
15+
model, input, output, output_selector::AbstractOutputSelector, backend::AbstractADType
16+
)
1717
output_selection = output_selector(output)
1818
dy = zero(output)
1919
dy[output_selection] .= 1
@@ -28,12 +28,12 @@ end
2828
2929
Analyze model by calculating the gradient of a neuron activation with respect to the input.
3030
"""
31-
struct Gradient{M,B<:AbstractADType} <: AbstractXAIMethod
31+
struct Gradient{M, B <: AbstractADType} <: AbstractXAIMethod
3232
model::M
3333
backend::B
3434

35-
function Gradient(model::M, backend::B=DEFAULT_AD_BACKEND) where {M,B<:AbstractADType}
36-
new{M,B}(model, backend)
35+
function Gradient(model::M, backend::B = DEFAULT_AD_BACKEND) where {M, B <: AbstractADType}
36+
return new{M, B}(model, backend)
3737
end
3838
end
3939

@@ -52,20 +52,20 @@ end
5252
Analyze model by calculating the gradient of a neuron activation with respect to the input.
5353
This gradient is then multiplied element-wise with the input.
5454
"""
55-
struct InputTimesGradient{M,B<:AbstractADType} <: AbstractXAIMethod
55+
struct InputTimesGradient{M, B <: AbstractADType} <: AbstractXAIMethod
5656
model::M
5757
backend::B
5858

5959
function InputTimesGradient(
60-
model::M, backend::B=DEFAULT_AD_BACKEND
61-
) where {M,B<:AbstractADType}
62-
new{M,B}(model, backend)
60+
model::M, backend::B = DEFAULT_AD_BACKEND
61+
) where {M, B <: AbstractADType}
62+
return new{M, B}(model, backend)
6363
end
6464
end
6565

6666
function call_analyzer(
67-
input, analyzer::InputTimesGradient, ns::AbstractOutputSelector; kwargs...
68-
)
67+
input, analyzer::InputTimesGradient, ns::AbstractOutputSelector; kwargs...
68+
)
6969
grad, output, output_indices = gradient_wrt_input(
7070
analyzer.model, input, ns, analyzer.backend
7171
)
@@ -91,7 +91,7 @@ e.g. `std = 0.1 * (maximum(input) - minimum(input))`.
9191
# References
9292
- $REF_SMILKOV_SMOOTHGRAD
9393
"""
94-
SmoothGrad(model, n=50, args...) = NoiseAugmentation(Gradient(model), n, args...)
94+
SmoothGrad(model, n = 50, args...) = NoiseAugmentation(Gradient(model), n, args...)
9595

9696
"""
9797
IntegratedGradients(analyzer, [n=50])
@@ -102,4 +102,4 @@ Analyze model by using the Integrated Gradients method.
102102
# References
103103
- $REF_SUNDARARAJAN_AXIOMATIC
104104
"""
105-
IntegratedGradients(model, n=50) = InterpolationAugmentation(Gradient(model), n)
105+
IntegratedGradients(model, n = 50) = InterpolationAugmentation(Gradient(model), n)

0 commit comments

Comments
 (0)