comparison LazyTensors/test/runtests.jl @ 186:715ff09bb2ce boundary_conditions

Rename and export types in LazyTensors follow julia conventions
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 20 Jun 2019 21:31:15 +0200
parents 6945c15a6a7a
children 25d2ef206fe9
comparison
equal deleted inserted replaced
185:67da5ce895d8 186:715ff09bb2ce
2 using LazyTensors 2 using LazyTensors
3 3
4 4
5 5
6 @testset "Generic Mapping methods" begin 6 @testset "Generic Mapping methods" begin
7 struct DummyMapping{T,R,D} <: LazyTensors.Mapping{T,R,D} end 7 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end
8 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply 8 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply
9 @test range_dim(DummyMapping{Int,2,3}()) == 2 9 @test range_dim(DummyMapping{Int,2,3}()) == 2
10 @test domain_dim(DummyMapping{Int,2,3}()) == 3 10 @test domain_dim(DummyMapping{Int,2,3}()) == 3
11 @test apply(DummyMapping{Int,2,3}(), zeros(Int, (0,0,0)),0) == :apply 11 @test apply(DummyMapping{Int,2,3}(), zeros(Int, (0,0,0)),0) == :apply
12 end 12 end
13 13
14 struct DummyOperator{T,D} <: LazyTensors.Operator{T,D} end
15 @testset "Generic Operator methods" begin 14 @testset "Generic Operator methods" begin
15 struct DummyOperator{T,D} <: TensorOperator{T,D} end
16 @test range_size(DummyOperator{Int,2}(), (3,5)) == (3,5) 16 @test range_size(DummyOperator{Int,2}(), (3,5)) == (3,5)
17 @test domain_size(DummyOperator{Float64, 3}(), (3,3,1)) == (3,3,1) 17 @test domain_size(DummyOperator{Float64, 3}(), (3,3,1)) == (3,3,1)
18 end 18 end
19 19
20 @testset "Mapping transpose" begin 20 @testset "Mapping transpose" begin
21 struct DummyMapping{T,R,D} <: LazyTensors.Mapping{T,R,D} end 21 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end
22 22
23 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply 23 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply
24 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose 24 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose
25 25
26 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size) where {T,R,D} = :range_size 26 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size) where {T,R,D} = :range_size
35 @test range_size(m', (0,0)) == :domain_size 35 @test range_size(m', (0,0)) == :domain_size
36 @test domain_size(m', (0,0,0)) == :range_size 36 @test domain_size(m', (0,0,0)) == :range_size
37 end 37 end
38 38
39 @testset "TensorApplication" begin 39 @testset "TensorApplication" begin
40 struct DummyMapping{T,R,D} <: LazyTensors.Mapping{T,R,D} end 40 struct DummyMapping{T,R,D} <: TensorMapping{T,R,D} end
41 41
42 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = (:apply,v,i) 42 LazyTensors.apply(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = (:apply,v,i)
43 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose 43 LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, i) where {T,R,D} = :apply_transpose
44 44
45 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size) where {T,R,D} = 2 .* domain_size 45 LazyTensors.range_size(m::DummyMapping{T,R,D}, domain_size) where {T,R,D} = 2 .* domain_size