diff src/LazyTensors/lazy_tensor_operations.jl @ 481:2fde16253a84 feature/compose_identity_mappings

Proposal for SizeMismatch exception
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 05 Nov 2020 10:25:30 +0100
parents c1a366331e75
children f0f272666a64
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Wed Nov 04 20:06:10 2020 +0100
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Thu Nov 05 10:25:30 2020 +0100
@@ -98,6 +98,17 @@
     end
 end
 
+struct SizeMismatch <: Exception
+    tm::TensorMapping
+    sz::NTuple{N,Int}
+end
+
+function showerror(io::IO, err::SizeMismatch)
+    print(io, "SizeMismatch: ")
+    print(io, "attempt to apply TensorMapping with domain size $(domain_size(tm)) to a domain of size $sz")
+end
+
+
 range_size(tm::TensorMappingComposition) = range_size(tm.t1)
 domain_size(tm::TensorMappingComposition) = domain_size(tm.t2)