Mercurial > repos > public > sbplib_julia
comparison LazyTensors/test/runtests.jl @ 232:a20bb4fac23d boundary_conditions
Improve tests for LazyTensors
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 26 Jun 2019 17:41:44 +0200 |
| parents | 2aa33d0eef90 |
| children | 856caf960d89 |
comparison
equal
deleted
inserted
replaced
| 230:3d94f60f6fae | 232:a20bb4fac23d |
|---|---|
| 19 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end | 19 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end |
| 20 | 20 |
| 21 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply | 21 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply |
| 22 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose | 22 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose |
| 23 | 23 |
| 24 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size) where {T,R,D} = :range_size | 24 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size::NTuple{D,Integer}) where {T,R,D} = :range_size |
| 25 LazyTensors.domain_size(m::DummyMapping{T,R,D}, range_size) where {T,R,D} = :domain_size | 25 LazyTensors.domain_size(m::DummyMapping{T,R,D}, range_size::NTuple{R,Integer}) where {T,R,D} = :domain_size |
| 26 | 26 |
| 27 m = DummyMapping{Float64,2,3}() | 27 m = DummyMapping{Float64,2,3}() |
| 28 @test m' isa TensorMapping{Float64, 3,2} | |
| 28 @test m'' == m | 29 @test m'' == m |
| 29 @test apply(m',zeros(Float64,(0,0)),0) == :apply_transpose | 30 @test apply(m',zeros(Float64,(0,0)),0) == :apply_transpose |
| 30 @test apply(m'',zeros(Float64,(0,0,0)),0) == :apply | 31 @test apply(m'',zeros(Float64,(0,0,0)),0) == :apply |
| 31 @test apply_transpose(m', zeros(Float64,(0,0,0)),0) == :apply | 32 @test apply_transpose(m', zeros(Float64,(0,0,0)),0) == :apply |
| 32 | 33 |
| 38 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end | 39 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end |
| 39 | 40 |
| 40 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = (:apply,v,i) | 41 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = (:apply,v,i) |
| 41 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose | 42 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose |
| 42 | 43 |
| 43 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size) where {T,R,D} = 2 .* domain_size | 44 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size::NTuple{D,Integer}) where {T,R,D} = 2 .* domain_size |
| 44 LazyTensors.domain_size(m::DummyMapping{T,R,D}, range_size) where {T,R,D} = range_size.÷2 | 45 LazyTensors.domain_size(m::DummyMapping{T,R,D}, range_size::NTuple{R,Integer}) where {T,R,D} = range_size.÷2 |
| 45 | 46 |
| 46 | 47 |
| 47 m = DummyMapping{Int, 1, 1}() | 48 m = DummyMapping{Int, 1, 1}() |
| 48 v = [0,1,2] | 49 v = [0,1,2] |
| 49 @test m*v isa AbstractVector{Int} | 50 @test m*v isa AbstractVector{Int} |
