Skip to content

Commit 4c34f5f

Browse files
authored
Merge pull request #396 from JuliaDiff/mz/dne
Update to using `DoesNotExist()` instead of `nothing` in tests
2 parents 38caf4b + 6cc0b54 commit 4c34f5f

File tree

11 files changed

+61
-61
lines changed

11 files changed

+61
-61
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1313

1414
[compat]
1515
ChainRulesCore = "0.9.29"
16-
ChainRulesTestUtils = "0.6.1"
16+
ChainRulesTestUtils = "0.6.6"
1717
Compat = "3"
1818
FiniteDifferences = "0.11, 0.12"
1919
Reexport = "0.2, 1"

test/rulesets/Base/array.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@testset "reshape" begin
2-
test_rrule(reshape, rand(4, 5), (2, 10) nothing)
3-
test_rrule(reshape, rand(4, 5), 2 nothing, 10 nothing)
2+
test_rrule(reshape, rand(4, 5), (2, 10) DoesNotExist())
3+
test_rrule(reshape, rand(4, 5), 2, 10)
44
end
55

66
@testset "hcat" begin
@@ -14,7 +14,7 @@ end
1414
A = randn(3, 2)
1515
B = randn(3, 1)
1616
C = randn(3, 3)
17-
test_rrule(reduce, hcat nothing, [A, B, C])
17+
test_rrule(reduce, hcat DoesNotExist(), [A, B, C])
1818
end
1919

2020
@testset "vcat" begin
@@ -28,10 +28,10 @@ end
2828
A = randn(2, 4)
2929
B = randn(1, 4)
3030
C = randn(3, 4)
31-
test_rrule(reduce, vcat nothing, [A, B, C])
31+
test_rrule(reduce, vcat DoesNotExist(), [A, B, C])
3232
end
3333

3434
@testset "fill" begin
35-
test_rrule(fill, 44.0, 4 nothing; check_inferred=false)
36-
test_rrule(fill, 2.0, (3, 3, 3) nothing)
35+
test_rrule(fill, 44.0, 4; check_inferred=false)
36+
test_rrule(fill, 2.0, (3, 3, 3) DoesNotExist())
3737
end

test/rulesets/Base/base.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989

9090
@testset "ldexp" begin
9191
for n in (0,1,20)
92-
test_frule(ldexp, 10rand(), n nothing)
93-
test_rrule(ldexp, 10rand(), n nothing)
92+
test_frule(ldexp, 10rand(), n)
93+
test_rrule(ldexp, 10rand(), n)
9494
end
9595
end
9696

test/rulesets/Base/indexing.jl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,48 @@
33
x = [1.0 2.0 3.0; 10.0 20.0 30.0]
44

55
@testset "single element" begin
6-
test_rrule(getindex, x, 2 nothing)
7-
test_rrule(getindex, x, 2 nothing, 1 nothing)
8-
test_rrule(getindex, x, 2 nothing, 2 nothing)
6+
test_rrule(getindex, x, 2)
7+
test_rrule(getindex, x, 2, 1)
8+
test_rrule(getindex, x, 2, 2)
99

10-
test_rrule(getindex, x, CartesianIndex(2, 3) nothing)
10+
test_rrule(getindex, x, CartesianIndex(2, 3) DoesNotExist())
1111
end
1212

1313
@testset "slice/index postions" begin
14-
test_rrule(getindex, x, 2:3 nothing)
15-
test_rrule(getindex, x, 3:-1:2 nothing)
16-
test_rrule(getindex, x, [3,2] nothing)
17-
test_rrule(getindex, x, [2,3] nothing)
14+
test_rrule(getindex, x, 2:3 DoesNotExist())
15+
test_rrule(getindex, x, 3:-1:2 DoesNotExist())
16+
test_rrule(getindex, x, [3,2] DoesNotExist())
17+
test_rrule(getindex, x, [2,3] DoesNotExist())
1818

19-
test_rrule(getindex, x, 1:2 nothing, 2:3 nothing)
20-
test_rrule(getindex, x, (:) nothing, 2:3 nothing)
19+
test_rrule(getindex, x, 1:2 DoesNotExist(), 2:3 DoesNotExist())
20+
test_rrule(getindex, x, (:) DoesNotExist(), 2:3 DoesNotExist())
2121

22-
test_rrule(getindex, x, 1:2 nothing, 1 nothing)
23-
test_rrule(getindex, x, 1 nothing, 1:2 nothing)
22+
test_rrule(getindex, x, 1:2 DoesNotExist(), 1)
23+
test_rrule(getindex, x, 1, 1:2 DoesNotExist())
2424

25-
test_rrule(getindex, x, 1:2 nothing, 2:3 nothing)
26-
test_rrule(getindex, x, (:) nothing, 2:3 nothing)
25+
test_rrule(getindex, x, 1:2 DoesNotExist(), 2:3 DoesNotExist())
26+
test_rrule(getindex, x, (:) DoesNotExist(), 2:3 DoesNotExist())
2727

28-
test_rrule(getindex, x, (:) nothing, (:) nothing)
29-
test_rrule(getindex, x, (:) nothing)
28+
test_rrule(getindex, x, (:) DoesNotExist(), (:) DoesNotExist())
29+
test_rrule(getindex, x, (:) DoesNotExist())
3030
end
3131

3232
@testset "masking" begin
33-
test_rrule(getindex, x, trues(size(x)) nothing)
34-
test_rrule(getindex, x, trues(length(x)) nothing)
33+
test_rrule(getindex, x, trues(size(x)) DoesNotExist())
34+
test_rrule(getindex, x, trues(length(x)) DoesNotExist())
3535

3636
mask = falses(size(x))
3737
mask[2,3] = true
3838
mask[1,2] = true
39-
test_rrule(getindex, x, mask nothing)
39+
test_rrule(getindex, x, mask DoesNotExist())
4040

41-
test_rrule(getindex, x, [true, false] nothing, (:) nothing)
41+
test_rrule(getindex, x, [true, false] DoesNotExist(), (:) DoesNotExist())
4242
end
4343

4444
@testset "By position with repeated elements" begin
45-
test_rrule(getindex, x, [2, 2] nothing)
46-
test_rrule(getindex, x, [2, 2, 2] nothing)
47-
test_rrule(getindex, x, [2,2] nothing, [3,3] nothing)
45+
test_rrule(getindex, x, [2, 2] DoesNotExist())
46+
test_rrule(getindex, x, [2, 2, 2] DoesNotExist())
47+
test_rrule(getindex, x, [2,2] DoesNotExist(), [3,3] DoesNotExist())
4848
end
4949
end
5050
end

test/rulesets/Base/mapreduce.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@testset "Array{$N, $T}" for N in eachindex(sizes), T in (Float64, ComplexF64)
1717
x = randn(T, sizes[1:N]...)
1818
test_frule(sum, abs2, x; fkwargs=(;dims=dims))
19-
test_rrule(sum, abs2 nothing, x; fkwargs=(;dims=dims))
19+
test_rrule(sum, abs2 DoesNotExist(), x; fkwargs=(;dims=dims))
2020
end
2121
end
2222
end # sum abs2

test/rulesets/Base/sort.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
end
77
@testset "partialsort" begin
88
a = rand(10)
9-
test_rrule(partialsort, a, 4 nothing)
10-
test_rrule(partialsort, a, 3:5 nothing)
11-
test_rrule(partialsort, a, 1:2:6 nothing)
9+
test_rrule(partialsort, a, 4)
10+
test_rrule(partialsort, a, 3:5 DoesNotExist())
11+
test_rrule(partialsort, a, 1:2:6 DoesNotExist())
1212

13-
test_rrule(partialsort, a, 4 nothing, fkwargs=(;rev=true))
13+
test_rrule(partialsort, a, 4, fkwargs=(;rev=true))
1414
end
1515
end

test/rulesets/LinearAlgebra/blas.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
incy = 3
1313
test_rrule(
1414
BLAS.dot,
15-
n nothing,
15+
n,
1616
randn(n * incx),
17-
incx nothing,
17+
incx,
1818
randn(n * incy),
19-
incy nothing,
19+
incy,
2020
)
2121
end
2222
end
@@ -37,7 +37,7 @@
3737
s = (dims[1] * incx, dims[2:N]...)
3838
n = div(prod(s), incx)
3939
test_rrule(
40-
BLAS.nrm2, n nothing, randn(T, s), incx nothing; atol=0, rtol=1e-5,
40+
BLAS.nrm2, n, randn(T, s), incx; atol=0, rtol=1e-5,
4141
)
4242
end
4343
end
@@ -58,7 +58,7 @@
5858
@testset "Array{$T,$N}" for N in eachindex(dims), T in (Float64, ComplexF64)
5959
s = (dims[1] * incx, dims[2:N]...)
6060
n = div(prod(s), incx)
61-
test_rrule( BLAS.asum, n nothing, randn(T, s), incx nothing)
61+
test_rrule(BLAS.asum, n, randn(T, s), incx)
6262
end
6363
end
6464
end
@@ -67,17 +67,17 @@
6767
for m in 3:5, n in 3:5, p in 3:5, tA in ('N', 'C', 'T'), tB in ('N', 'C', 'T'), T in (Float64, ComplexF64)
6868
A = randn(T, tA === 'N' ? (m, n) : (n, m))
6969
B = randn(T, tB === 'N' ? (n, p) : (p, n))
70-
test_rrule(gemm, tA nothing, tB nothing, A, B; check_inferred=false)
70+
test_rrule(gemm, tA, tB, A, B; check_inferred=false)
7171
test_rrule( # 5 arg version with scaling scalar
72-
gemm, tA nothing, tB nothing, randn(T), A, B; check_inferred=false,
72+
gemm, tA, tB, randn(T), A, B; check_inferred=false,
7373
)
7474
end
7575
end
7676

7777
@testset "gemv" begin
7878
for n in 3:5, m in 3:5, t in ('N', 'C', 'T'), T in (Float64, ComplexF64)
7979
x = randn(T, t === 'N' ? n : m)
80-
test_rrule(gemv, t nothing, randn(T), randn(T, m, n), x; check_inferred=false)
80+
test_rrule(gemv, t, randn(T), randn(T, m, n), x; check_inferred=false)
8181
end
8282
end
8383
end

test/rulesets/LinearAlgebra/factorization.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
pivot in (Val(true), Val(false)),
3030
m in (7, 10, 13)
3131

32-
test_frule(lu!, randn(T, m, n), pivot nothing)
32+
test_frule(lu!, randn(T, m, n), pivot DoesNotExist())
3333
end
3434
@testset "check=false passed to primal function" begin
3535
Asingular = zeros(n, n)
@@ -47,7 +47,7 @@ end
4747
pivot in (Val(true), Val(false)),
4848
m in (7, 10, 13)
4949

50-
test_rrule(lu, randn(T, m, n), pivot nothing)
50+
test_rrule(lu, randn(T, m, n), pivot DoesNotExist())
5151
end
5252
@testset "check=false passed to primal function" begin
5353
Asingular = zeros(n, n)
@@ -67,7 +67,7 @@ end
6767
m in (7, 10, 13)
6868

6969
F = lu(randn(m, n))
70-
test_rrule(getproperty, F, k nothing ; check_inferred=false)
70+
test_rrule(getproperty, F, k; check_inferred=false)
7171
end
7272
end
7373
@testset "matrix inverse using LU" begin
@@ -93,10 +93,10 @@ end
9393
F = svd(X)
9494
rand_adj = adjoint(rand(reverse(size(F.V))...))
9595

96-
test_rrule(getproperty, F, :U nothing; check_inferred=false)
97-
test_rrule(getproperty, F, :S nothing; check_inferred=false)
98-
test_rrule(getproperty, F, :Vt nothing; check_inferred=false)
99-
test_rrule(getproperty, F, :V nothing; check_inferred=false, output_tangent=rand_adj)
96+
test_rrule(getproperty, F, :U; check_inferred=false)
97+
test_rrule(getproperty, F, :S; check_inferred=false)
98+
test_rrule(getproperty, F, :Vt; check_inferred=false)
99+
test_rrule(getproperty, F, :V; check_inferred=false, output_tangent=rand_adj)
100100
end
101101
end
102102

@@ -364,7 +364,7 @@ end
364364
D = Diagonal(rand(5) .+ 0.1)
365365
C = cholesky(D)
366366
test_rrule(
367-
cholesky, D Diagonal(randn(5)), Val(false) nothing;
367+
cholesky, D Diagonal(randn(5)), Val(false) DoesNotExist();
368368
output_tangent=Composite{typeof(C)}(factors=Diagonal(randn(5)))
369369
)
370370
end

test/rulesets/LinearAlgebra/lapack.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
C = randn(T, m, n)
1616
test_frule(
1717
LAPACK.trsyl!,
18-
transa nothing,
19-
transb nothing,
18+
transa,
19+
transb,
2020
A rand_tangent(A) .* (!iszero).(A), # Match sparsity pattern
2121
B rand_tangent(B) .* (!iszero).(B),
2222
C,
23-
isgn nothing,
23+
isgn,
2424
)
2525
end
2626
end

test/rulesets/LinearAlgebra/structured.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
test_rrule(diag, randn(N, N) Diagonal(randn(N)))
4343
test_rrule(diag, Diagonal(randn(N)) Diagonal(randn(N)))
4444
VERSION v"1.3" && @testset "k=$k" for k in (-1, 0, 2)
45-
test_rrule(diag, randn(N, N), k nothing)
45+
test_rrule(diag, randn(N, N), k)
4646
end
4747
end
4848
@testset "diagm" begin
@@ -138,7 +138,7 @@
138138
n = 7
139139
test_rrule(Op, randn(n, n))
140140
@testset "k=$k" for k in -2:2
141-
test_rrule(Op, randn(n, n), k nothing)
141+
test_rrule(Op, randn(n, n), k)
142142
end
143143
end
144144

0 commit comments

Comments
 (0)