changeset 421:2808c41f5efa bugfix/tensor_application_multiplication

Change defs of * for TensorApplication to fix bug
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 18 Oct 2020 22:09:17 +0200
parents 3796e296fe64
children f0d6906d8937
files src/LazyTensors/lazy_tensor_operations.jl test/runtests.jl
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
diff -r 3796e296fe64 -r 2808c41f5efa src/LazyTensors/lazy_tensor_operations.jl
--- a/src/LazyTensors/lazy_tensor_operations.jl	Sun Oct 18 21:52:56 2020 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Sun Oct 18 22:09:17 2020 +0200
@@ -16,14 +16,16 @@
 
 # TODO: Go through and remove unneccerary type parameters on functions
 
-Base.:*(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o)
 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Index,R}) where {T,R,D} = apply(ta.t, ta.o, I...)
 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Int,R}) where {T,R,D} = apply(ta.t, ta.o, Index{Unknown}.(I)...)
 Base.size(ta::LazyTensorMappingApplication) = range_size(ta.t)
 # TODO: What else is needed to implement the AbstractArray interface?
 
+Base.:*(a::TensorMapping, v::AbstractArray) = LazyTensorMappingApplication(a,v)
+Base.:*(a::TensorMapping, b::TensorMapping) = throw(MethodError(Base.:*,(a,b)))
+Base.:*(a::TensorMapping, args::Union{TensorMapping, AbstractArray}...) = foldr(*,(a,args...))
+
 # # We need the associativity to be a→b→c = a→(b→c), which is the case for '→'
-Base.:*(a::TensorMapping{T,R,D}, b::TensorMapping{T,D,K}, args::Union{TensorMapping{T}, AbstractArray{T}}...) where {T,R,D,K} = foldr(*,(a,b,args...))
 # # Should we overload some other infix binary opesrator?
 # →(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o)
 # TODO: We need to be really careful about good error messages.
diff -r 3796e296fe64 -r 2808c41f5efa test/runtests.jl
--- a/test/runtests.jl	Sun Oct 18 21:52:56 2020 +0200
+++ b/test/runtests.jl	Sun Oct 18 22:09:17 2020 +0200
@@ -1,6 +1,6 @@
 using Test
 using TestSetExtensions
 
-@testset ExtendedTestSet "All" begin
+@testset "All" begin
     @includetests ARGS
 end