Mercurial > repos > public > sbplib_julia
diff LazyTensors/test/runtests.jl @ 257:d4cd4882ee9f boundary_conditions
Improve error messages when multiblying with TensorMappings and add some tests for TensorOperators
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 28 Jun 2019 14:10:35 +0200 |
parents | 1c6afdcfd657 |
children | b577b5f64530 |
line wrap: on
line diff
--- a/LazyTensors/test/runtests.jl Fri Jun 28 14:08:30 2019 +0200 +++ b/LazyTensors/test/runtests.jl Fri Jun 28 14:10:35 2019 +0200 @@ -56,6 +56,22 @@ @test (m*m*v)[6] == (:apply,m*v,(6,)) @test_broken BoundsError == (m*m*v)[0] @test_broken BoundsError == (m*m*v)[7] + + A = DummyMapping{Int, 2, 1}() + + @test_throws MethodError A*ones(Int,2,2) + @test_throws MethodError A*A*v + + struct ScalingOperator{T,D} <: TensorOperator{T,D} + λ::T + end + + LazyTensors.apply(m::ScalingOperator{T,D}, v, I::Tuple{Int}) where {T,D} = m.λ*v[I...] + + A = ScalingOperator{Int,1}(2) + + @test A*[1,2,3] isa AbstractVector + @test A*[1,2,3] == [2,4,6] end @testset "TensorMapping binary operations" begin