Skip to content

Commit ed7c0a0

Browse files
authored
Test type stability with JET.jl (#163)
* Add JET and JuliaFormatter tests * Make individual tests modular for use with TestEnv.jl
1 parent 1bcee29 commit ed7c0a0

7 files changed

+37
-12
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
1313

1414
[compat]
1515
Distributions = "0.25"
16-
Random = "1"
16+
Random = "<0.0.1, 1"
1717
Reexport = "1"
1818
Statistics = "1"
1919
XAIBase = "3"

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ___
33

44
| **Documentation** | **Build Status** | **DOI** |
55
|:----------------- |:---------------- |:------- |
6-
| [![][docs-stab-img]][docs-stab-url] [![][docs-dev-img]][docs-dev-url] | [![][ci-img]][ci-url] [![][codecov-img]][codecov-url] [![Aqua QA][aqua-img]][aqua-url] | [![][doi-img]][doi-url] |
6+
| [![][docs-stab-img]][docs-stab-url] [![][docs-dev-img]][docs-dev-url] | [![][ci-img]][ci-url] [![][codecov-img]][codecov-url] [![Aqua][aqua-img]][aqua-url] [![JET][jet-img]][jet-url] | [![][doi-img]][doi-url] |
77

88
Explainable AI in Julia.
99

@@ -165,6 +165,9 @@ Contributions are welcome!
165165
[aqua-img]: https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg
166166
[aqua-url]: https://github.com/JuliaTesting/Aqua.jl
167167

168+
[jet-img]: https://img.shields.io/badge/%F0%9F%9B%A9%EF%B8%8F_tested_with-JET.jl-233f9a
169+
[jet-url]: https://github.com/aviatesk/JET.jl
170+
168171
[docs-composites]: https://julia-xai.github.io/ExplainableAI.jl/stable/generated/lrp/composites/
169172
[docs-custom-rules]: https://julia-xai.github.io/ExplainableAI.jl/stable/generated/lrp/custom_rules/
170173

test/Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
44
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
5+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
56
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
7+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
68
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
79
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
810
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
911
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
1012
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1113
XAIBase = "9b48221d-a747-4c1b-9860-46a1d8ba24a7"
12-

test/runtests.jl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
using ExplainableAI
2-
using Flux
2+
33
using Test
4-
using ReferenceTests
4+
using JuliaFormatter
55
using Aqua
6-
using Random
7-
8-
pseudorand(dims...) = rand(MersenneTwister(123), Float32, dims...)
6+
using JET
97

108
@testset "ExplainableAI.jl" begin
11-
@testset "Aqua.jl" begin
12-
@info "Running Aqua.jl's auto quality assurance tests. These might print warnings from dependencies."
13-
Aqua.test_all(ExplainableAI; ambiguities=false)
9+
@info "Testing formalities..."
10+
if VERSION >= v"1.10"
11+
@testset "Code formatting" begin
12+
@info "- Testing code formatting with JuliaFormatter..."
13+
@test JuliaFormatter.format(ExplainableAI; verbose=false, overwrite=false)
14+
end
15+
@testset "Aqua.jl" begin
16+
@info "- Running Aqua.jl tests. These might print warnings from dependencies..."
17+
Aqua.test_all(ExplainableAI; ambiguities=false)
18+
end
19+
@testset "JET tests" begin
20+
@info "- Testing type stability with JET..."
21+
JET.test_package(ExplainableAI; target_defined_modules=true)
22+
end
1423
end
24+
1525
@testset "Input augmentation" begin
1626
@info "Testing input augmentation..."
1727
include("test_input_augmentation.jl")

test/test_batches.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
using Flux
21
using ExplainableAI
2+
using Test
3+
4+
using Flux
35
using Random
46
using Distributions: Laplace
57

8+
pseudorand(dims...) = rand(MersenneTwister(123), Float32, dims...)
9+
610
## Test `fuse_batchnorm` on Dense and Conv layers
711
ins = 20
812
outs = 10

test/test_cnn.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using ExplainableAI
2+
using Test
3+
using ReferenceTests
4+
25
using Flux
6+
using Random
37
using JLD2
48

59
const GRADIENT_ANALYZERS = Dict(
@@ -9,6 +13,8 @@ const GRADIENT_ANALYZERS = Dict(
913
"GradCAM" => m -> GradCAM(m[1], m[2]),
1014
)
1115

16+
pseudorand(dims...) = rand(MersenneTwister(123), Float32, dims...)
17+
1218
input_size = (32, 32, 3, 1)
1319
input = pseudorand(input_size)
1420

test/test_input_augmentation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using ExplainableAI: augment_batch_dim, augment_indices, reduce_augmentation
22
using ExplainableAI: interpolate_batch
3+
using Test
34

45
# augment_batch_dim
56
A = [1 2; 3 4]

0 commit comments

Comments
 (0)