Mercurial > repos > public > sbplib_julia
comparison LazyTensors/test/runtests.jl @ 236:856caf960d89 boundary_conditions
Use CartesianIndex for a bunch of index operations
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 26 Jun 2019 18:24:07 +0200 |
| parents | a20bb4fac23d |
| children | 1c6afdcfd657 |
comparison
equal
deleted
inserted
replaced
| 235:a5fdc00d5070 | 236:856caf960d89 |
|---|---|
| 1 using Test | 1 using Test |
| 2 using LazyTensors | 2 using LazyTensors |
| 3 | 3 |
| 4 @testset "Generic Mapping methods" begin | 4 @testset "Generic Mapping methods" begin |
| 5 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end | 5 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end |
| 6 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply | 6 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i::CartesianIndex{R}) where {T,R,D} = :apply |
| 7 @test range_dim(DummyMapping{Int,2,3}()) == 2 | 7 @test range_dim(DummyMapping{Int,2,3}()) == 2 |
| 8 @test domain_dim(DummyMapping{Int,2,3}()) == 3 | 8 @test domain_dim(DummyMapping{Int,2,3}()) == 3 |
| 9 @test apply(DummyMapping{Int,2,3}(), zeros(Int, (0,0,0)),0) == :apply | 9 @test apply(DummyMapping{Int,2,3}(), zeros(Int, (0,0,0)),CartesianIndex(0,0)) == :apply |
| 10 end | 10 end |
| 11 | 11 |
| 12 @testset "Generic Operator methods" begin | 12 @testset "Generic Operator methods" begin |
| 13 struct DummyOperator{T,D} <: TensorOperator{T,D} end | 13 struct DummyOperator{T,D} <: TensorOperator{T,D} end |
| 14 @test range_size(DummyOperator{Int,2}(), (3,5)) == (3,5) | 14 @test range_size(DummyOperator{Int,2}(), (3,5)) == (3,5) |
| 16 end | 16 end |
| 17 | 17 |
| 18 @testset "Mapping transpose" begin | 18 @testset "Mapping transpose" begin |
| 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::CartesianIndex{R}) 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::CartesianIndex{D}) where {T,R,D} = :apply_transpose |
| 23 | 23 |
| 24 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size::NTuple{D,Integer}) 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::NTuple{R,Integer}) 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' isa TensorMapping{Float64, 3,2} |
| 29 @test m'' == m | 29 @test m'' == m |
| 30 @test apply(m',zeros(Float64,(0,0)),0) == :apply_transpose | 30 @test apply(m',zeros(Float64,(0,0)),CartesianIndex(0,0,0)) == :apply_transpose |
| 31 @test apply(m'',zeros(Float64,(0,0,0)),0) == :apply | 31 @test apply(m'',zeros(Float64,(0,0,0)),CartesianIndex(0,0)) == :apply |
| 32 @test apply_transpose(m', zeros(Float64,(0,0,0)),0) == :apply | 32 @test apply_transpose(m', zeros(Float64,(0,0,0)),CartesianIndex(0,0)) == :apply |
| 33 | 33 |
| 34 @test range_size(m', (0,0)) == :domain_size | 34 @test range_size(m', (0,0)) == :domain_size |
| 35 @test domain_size(m', (0,0,0)) == :range_size | 35 @test domain_size(m', (0,0,0)) == :range_size |
| 36 end | 36 end |
| 37 | 37 |
