changeset 277:21e5c1dd6794 boundary_conditions

Add getindex-function for region indices. Update LazyArray tests. NOTE: Not sure if this is the way to go.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 06 Jan 2020 12:08:00 +0100
parents e3611c2181bc
children d6edd37551ea
files LazyTensors/test/runtests.jl RegionIndices/src/RegionIndices.jl
diffstat 2 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/LazyTensors/test/runtests.jl	Mon Jan 06 11:46:21 2020 +0100
+++ b/LazyTensors/test/runtests.jl	Mon Jan 06 12:08:00 2020 +0100
@@ -71,7 +71,7 @@
     v = ones(3,3)
     I = (Index{Lower}(1),Index{Interior}(2));
     @test size(m*v) == 2 .*size(v)
-    @test (m*v)[I...] == (:apply,v,I)
+    @test (m*v)[I] == (:apply,v,I)
 
     struct ScalingOperator{T,D} <: TensorOperator{T,D}
         λ::T
--- a/RegionIndices/src/RegionIndices.jl	Mon Jan 06 11:46:21 2020 +0100
+++ b/RegionIndices/src/RegionIndices.jl	Mon Jan 06 12:08:00 2020 +0100
@@ -31,6 +31,7 @@
 
 Base.Int(I::Index) = I.i
 Base.to_index(I::Index) = Int(I) #How to get this to work for all cases??
+Base.getindex(A::AbstractArray{T,N}, I::NTuple{N,Index}) where {T,N} = A[I...] #Is this ok??
 
 function Index(i::Integer, boundary_width::Integer, dim_size::Integer)
     return Index{getregion(i,boundary_width,dim_size)}(i)