Skip to content

Commit 4acc061

Browse files
author
Miha Zgubic
committed
Revert "change to new tests"
This reverts commit dcbd099.
1 parent dcbd099 commit 4acc061

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

test/rulesets/Base/indexing.jl

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
11
@testset "getindex" begin
22
@testset "getindex(::Matrix{<:Number},...)" begin
33
x = [1.0 2.0 3.0; 10.0 20.0 30.0]
4+
= [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]
46

57
@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)
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))
911

10-
test_rrule(getindex, x, CartesianIndex(2, 3) nothing)
12+
rrule_test(getindex, 2.3, (x, x̄), (CartesianIndex(2, 3), nothing))
1113
end
1214

1315
@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)
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))
1820

19-
test_rrule(getindex, x, 1:2 nothing, 2:3 nothing)
20-
test_rrule(getindex, x, (:) nothing, 2:3 nothing)
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))
2123

22-
test_rrule(getindex, x, 1:2 nothing, 1 nothing)
23-
test_rrule(getindex, x, 1 nothing, 1:2 nothing)
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))
2426

25-
test_rrule(getindex, x, 1:2 nothing, 2:3 nothing)
26-
test_rrule(getindex, x, (:) nothing, 2:3 nothing)
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))
2729

28-
test_rrule(getindex, x, (:) nothing, (:) nothing)
29-
test_rrule(getindex, x, (:) nothing)
30+
31+
rrule_test(getindex, full_ȳ, (x, x̄), (:, nothing), (:, nothing))
32+
rrule_test(getindex, full_ȳ[:], (x, x̄), (:, nothing))
3033
end
3134

3235
@testset "masking" begin
33-
test_rrule(getindex, x, trues(size(x)) nothing)
34-
test_rrule(getindex, x, trues(length(x)) nothing)
36+
rrule_test(getindex, full_ȳ, (x, x̄), (trues(size(x)), nothing))
37+
rrule_test(getindex, full_ȳ[:], (x, x̄), (trues(length(x)), nothing))
3538

3639
mask = falses(size(x))
3740
mask[2,3] = true
3841
mask[1,2] = true
39-
test_rrule(getindex, x, mask nothing)
42+
rrule_test(getindex, [2.3, 3.1], (x, x̄), (mask, nothing))
4043

41-
test_rrule(getindex, x, [true, false] nothing, (:) nothing)
44+
rrule_test(
45+
getindex, full_ȳ[1,:], (x, x̄), ([true, false], nothing), (:, nothing)
46+
)
4247
end
4348

4449
@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)
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+
)
4855
end
4956
end
5057
end

0 commit comments

Comments
 (0)