Mercurial > repos > public > sbplib_julia
comparison test/LazyTensors/tuple_manipulation_test.jl @ 1237:66012b95fa7b refactor/LazyTensors/tuple_manipulation
Improve readability
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Mon, 20 Feb 2023 20:35:52 +0100 |
| parents | de6a9635f293 |
| children | 471a948cd2b2 |
comparison
equal
deleted
inserted
replaced
| 1231:de6a9635f293 | 1237:66012b95fa7b |
|---|---|
| 10 @test LazyTensors.split_index(1,2,2,3, 1,2,3,4,5,6) == ((1,:,:,4,5,6),(2,3)) | 10 @test LazyTensors.split_index(1,2,2,3, 1,2,3,4,5,6) == ((1,:,:,4,5,6),(2,3)) |
| 11 | 11 |
| 12 @test LazyTensors.split_index(0,1,3,3, 1,2,3,4,5,6) == ((:,4,5,6),(1,2,3)) | 12 @test LazyTensors.split_index(0,1,3,3, 1,2,3,4,5,6) == ((:,4,5,6),(1,2,3)) |
| 13 @test LazyTensors.split_index(3,1,3,0, 1,2,3,4,5,6) == ((1,2,3,:),(4,5,6)) | 13 @test LazyTensors.split_index(3,1,3,0, 1,2,3,4,5,6) == ((1,2,3,:),(4,5,6)) |
| 14 | 14 |
| 15 split_index_static(::Val{dim_before}, ::Val{dim_view}, ::Val{dim_index}, ::Val{dim_after}, I...) where {dim_before,dim_view,dim_index,dim_after} = LazyTensors.split_index(dim_before, dim_view, dim_index, dim_after, I...) | 15 split_index_static(::Val{dim_before}, |
| 16 ::Val{dim_view}, | |
| 17 ::Val{dim_index}, | |
| 18 ::Val{dim_after}, I...) where {dim_before,dim_view,dim_index,dim_after} = | |
| 19 LazyTensors.split_index(dim_before, dim_view, dim_index, dim_after, I...) | |
| 16 @inferred split_index_static(Val(2),Val(3),Val(2),Val(2),1,2,3,2,2,4) | 20 @inferred split_index_static(Val(2),Val(3),Val(2),Val(2),1,2,3,2,2,4) |
| 17 end | 21 end |
| 18 | 22 |
| 19 @testset "split_tuple" begin | 23 @testset "split_tuple" begin |
| 20 @testset "general" begin | 24 @testset "general" begin |
| 64 | 68 |
| 65 @testset "left_pad_tuple" begin | 69 @testset "left_pad_tuple" begin |
| 66 @test LazyTensors.left_pad_tuple((1,2), 0, 2) == (1,2) | 70 @test LazyTensors.left_pad_tuple((1,2), 0, 2) == (1,2) |
| 67 @test LazyTensors.left_pad_tuple((1,2), 0, 3) == (0,1,2) | 71 @test LazyTensors.left_pad_tuple((1,2), 0, 3) == (0,1,2) |
| 68 @test LazyTensors.left_pad_tuple((3,2), 1, 6) == (1,1,1,1,3,2) | 72 @test LazyTensors.left_pad_tuple((3,2), 1, 6) == (1,1,1,1,3,2) |
| 69 | 73 err_msg = "Can't pad tuple of length 2 to 0 elements" |
| 70 @test_throws DomainError(0, "Can't pad tuple of length 2 to 0 elements") LazyTensors.left_pad_tuple((1,2), 0, 0) == (1,2) | 74 @test_throws DomainError(0, err_msg) LazyTensors.left_pad_tuple((1,2), 0, 0) == (1,2) |
| 71 end | 75 end |
| 72 | 76 |
| 73 @testset "right_pad_tuple" begin | 77 @testset "right_pad_tuple" begin |
| 74 @test LazyTensors.right_pad_tuple((1,2), 0, 2) == (1,2) | 78 @test LazyTensors.right_pad_tuple((1,2), 0, 2) == (1,2) |
| 75 @test LazyTensors.right_pad_tuple((1,2), 0, 3) == (1,2,0) | 79 @test LazyTensors.right_pad_tuple((1,2), 0, 3) == (1,2,0) |
| 76 @test LazyTensors.right_pad_tuple((3,2), 1, 6) == (3,2,1,1,1,1) | 80 @test LazyTensors.right_pad_tuple((3,2), 1, 6) == (3,2,1,1,1,1) |
| 77 | 81 err_msg = "Can't pad tuple of length 2 to 0 elements" |
| 78 @test_throws DomainError(0, "Can't pad tuple of length 2 to 0 elements") LazyTensors.right_pad_tuple((1,2), 0, 0) == (1,2) | 82 @test_throws DomainError(0,err_msg) LazyTensors.right_pad_tuple((1,2), 0, 0) == (1,2) |
| 79 end | 83 end |
