|
1 | 1 | @testset "getindex" begin
|
2 | 2 | @testset "getindex(::Matrix{<:Number},...)" begin
|
3 | 3 | x = [1.0 2.0 3.0; 10.0 20.0 30.0]
|
4 |
| - x̄ = [1.4 2.5 3.7; 10.5 20.1 30.2] |
5 |
| - full_ȳ = [7.4 5.5 2.7; 8.5 11.1 4.2] |
6 | 4 |
|
7 | 5 | @testset "single element" begin
|
8 |
| - rrule_test(getindex, 2.3, (x, x̄), (2, nothing)) |
9 |
| - rrule_test(getindex, 2.3, (x, x̄), (2, nothing), (1, nothing)) |
10 |
| - rrule_test(getindex, 2.3, (x, x̄), (2, nothing), (2, nothing)) |
| 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) |
11 | 9 |
|
12 |
| - rrule_test(getindex, 2.3, (x, x̄), (CartesianIndex(2, 3), nothing)) |
| 10 | + test_rrule(getindex, x, CartesianIndex(2, 3) ⊢ nothing) |
13 | 11 | end
|
14 | 12 |
|
15 | 13 | @testset "slice/index postions" begin
|
16 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), (2:3, nothing)) |
17 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), (3:-1:2, nothing)) |
18 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), ([3,2], nothing)) |
19 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), ([2,3], nothing)) |
| 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) |
20 | 18 |
|
21 |
| - rrule_test(getindex, [2.3 3.1; 4.1 5.1], (x, x̄), (1:2, nothing), (2:3, nothing)) |
22 |
| - rrule_test(getindex, [2.3 3.1; 4.1 5.1], (x, x̄), (:, nothing), (2:3, nothing)) |
| 19 | + test_rrule(getindex, x, 1:2 ⊢ nothing, 2:3 ⊢ nothing) |
| 20 | + test_rrule(getindex, x, (:) ⊢ nothing, 2:3 ⊢ nothing) |
23 | 21 |
|
24 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), (1:2, nothing), (1, nothing)) |
25 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), (1, nothing), (1:2, nothing)) |
| 22 | + test_rrule(getindex, x, 1:2 ⊢ nothing, 1 ⊢ nothing) |
| 23 | + test_rrule(getindex, x, 1 ⊢ nothing, 1:2 ⊢ nothing) |
26 | 24 |
|
27 |
| - rrule_test(getindex, [2.3 3.1; 4.1 5.1], (x, x̄), (1:2, nothing), (2:3, nothing)) |
28 |
| - rrule_test(getindex, [2.3 3.1; 4.1 5.1], (x, x̄), (:, nothing), (2:3, nothing)) |
| 25 | + test_rrule(getindex, x, 1:2 ⊢ nothing, 2:3 ⊢ nothing) |
| 26 | + test_rrule(getindex, x, (:) ⊢ nothing, 2:3 ⊢ nothing) |
29 | 27 |
|
30 |
| - |
31 |
| - rrule_test(getindex, full_ȳ, (x, x̄), (:, nothing), (:, nothing)) |
32 |
| - rrule_test(getindex, full_ȳ[:], (x, x̄), (:, nothing)) |
| 28 | + test_rrule(getindex, x, (:) ⊢ nothing, (:) ⊢ nothing) |
| 29 | + test_rrule(getindex, x, (:) ⊢ nothing) |
33 | 30 | end
|
34 | 31 |
|
35 | 32 | @testset "masking" begin
|
36 |
| - rrule_test(getindex, full_ȳ, (x, x̄), (trues(size(x)), nothing)) |
37 |
| - rrule_test(getindex, full_ȳ[:], (x, x̄), (trues(length(x)), nothing)) |
| 33 | + test_rrule(getindex, x, trues(size(x)) ⊢ nothing) |
| 34 | + test_rrule(getindex, x, trues(length(x)) ⊢ nothing) |
38 | 35 |
|
39 | 36 | mask = falses(size(x))
|
40 | 37 | mask[2,3] = true
|
41 | 38 | mask[1,2] = true
|
42 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), (mask, nothing)) |
| 39 | + test_rrule(getindex, x, mask ⊢ nothing) |
43 | 40 |
|
44 |
| - rrule_test( |
45 |
| - getindex, full_ȳ[1,:], (x, x̄), ([true, false], nothing), (:, nothing) |
46 |
| - ) |
| 41 | + test_rrule(getindex, x, [true, false] ⊢ nothing, (:) ⊢ nothing) |
47 | 42 | end
|
48 | 43 |
|
49 | 44 | @testset "By position with repeated elements" begin
|
50 |
| - rrule_test(getindex, [2.3, 3.1], (x, x̄), ([2, 2], nothing)) |
51 |
| - rrule_test(getindex, [2.3, 3.1, 4.1], (x, x̄), ([2, 2, 2], nothing)) |
52 |
| - rrule_test( |
53 |
| - getindex, [2.3 3.1; 4.1 5.1], (x, x̄), ([2,2], nothing), ([3,3], nothing) |
54 |
| - ) |
| 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) |
55 | 48 | end
|
56 | 49 | end
|
57 | 50 | end
|
0 commit comments