Mercurial > repos > public > sbplib_julia
comparison LazyTensors/test/runtests.jl @ 204:9d9f7b0e514b boundary_conditions
Modify the implementation of elementwise operations to be more direct and add a few tests
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Mon, 24 Jun 2019 14:04:38 +0200 |
| parents | b5c9be7f391c |
| children | 70e1f3401d82 |
comparison
equal
deleted
inserted
replaced
| 198:b5c9be7f391c | 204:9d9f7b0e514b |
|---|---|
| 54 @test (m*m*v)[3] == (:apply,m*v,3) | 54 @test (m*m*v)[3] == (:apply,m*v,3) |
| 55 @test (m*m*v)[6] == (:apply,m*v,6) | 55 @test (m*m*v)[6] == (:apply,m*v,6) |
| 56 @test_broken BoundsError == (m*m*v)[0] | 56 @test_broken BoundsError == (m*m*v)[0] |
| 57 @test_broken BoundsError == (m*m*v)[7] | 57 @test_broken BoundsError == (m*m*v)[7] |
| 58 end | 58 end |
| 59 | |
| 60 | |
| 61 @testset "Lazy elementwise operations" begin | |
| 62 struct DummyLazyArray{D} <: LazyArray{Int,D} | |
| 63 size::NTuple{D,Int} | |
| 64 end | |
| 65 Base.size(a::DummyLazyArray) = a.size | |
| 66 Base.getindex(a::DummyLazyArray, I...) = prod(I) | |
| 67 | |
| 68 | |
| 69 a = DummyLazyArray((3,)) | |
| 70 | |
| 71 @test (a+a)[3] == 6 | |
| 72 @test (a-a)[3] == 0 | |
| 73 @test (a*a)[3] == 9 | |
| 74 | |
| 75 a = DummyLazyArray((4,)) | |
| 76 b = [3,2,1,2] | |
| 77 | |
| 78 @test (a+b)[4] == 6 | |
| 79 @test (a-b)[4] == 2 | |
| 80 @test (a*b)[4] == 8 | |
| 81 | |
| 82 @test (b+a)[4] == 6 | |
| 83 @test (b-a)[4] == -2 | |
| 84 @test (b*a)[4] == 8 | |
| 85 end |
