Mercurial > repos > public > sbplib_julia
comparison LazyTensors/test/runtests.jl @ 207:f85a0b38f3ff boundary_conditions
Change error type when doing element wise operations on lazy arrays of missmatching dimension
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 24 Jun 2019 15:54:47 +0200 |
parents | 7b0650021b36 |
children | 992969237359 |
comparison
equal
deleted
inserted
replaced
206:7b0650021b36 | 207:f85a0b38f3ff |
---|---|
82 @test (v1 /̃ v2)[i] == r_div[i] | 82 @test (v1 /̃ v2)[i] == r_div[i] |
83 end | 83 end |
84 @test_throws BoundsError (v1 +̃ v2)[4] | 84 @test_throws BoundsError (v1 +̃ v2)[4] |
85 v2 = [1., 2, 3, 4] | 85 v2 = [1., 2, 3, 4] |
86 # Test that size of arrays is asserted when not specified inbounds | 86 # Test that size of arrays is asserted when not specified inbounds |
87 @test_throws AssertionError v1 +̃ v2 | 87 @test_throws DimensionMismatch v1 +̃ v2 |
88 # Test that no error checking is performed when specified inbounds | 88 # Test that no error checking is performed when specified inbounds |
89 res = (v1,v2) -> (@inbounds (v1 +̃ v2)[1] == 2) | 89 res = (v1,v2) -> (@inbounds (v1 +̃ v2)[1] == 2) |
90 @test res(v1,v2) | 90 @test res(v1,v2) |
91 | 91 |
92 # Test operations on LazyArray | 92 # Test operations on LazyArray |
101 @test (v1 - v2)[i] == -(v2 - v1)[i] == r_sub[i] | 101 @test (v1 - v2)[i] == -(v2 - v1)[i] == r_sub[i] |
102 end | 102 end |
103 @test_throws BoundsError (v1 + v2)[4] | 103 @test_throws BoundsError (v1 + v2)[4] |
104 v2 = [1., 2, 3, 4] | 104 v2 = [1., 2, 3, 4] |
105 # Test that size of arrays is asserted when not specified inbounds | 105 # Test that size of arrays is asserted when not specified inbounds |
106 @test_throws AssertionError v1 + v2 | 106 @test_throws DimensionMismatch v1 + v2 |
107 # Test that no error checking is performed when specified inbounds | 107 # Test that no error checking is performed when specified inbounds |
108 res = (v1,v2) -> (@inbounds (v1 + v2)[1] == 2) | 108 res = (v1,v2) -> (@inbounds (v1 + v2)[1] == 2) |
109 @test res(v1,v2) | 109 @test res(v1,v2) |
110 end | 110 end |