Mercurial > repos > public > sbplib_julia
changeset 968:997ea308aeca feature/laplace_opset
Merge with default
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 14 Mar 2022 15:53:11 +0100 |
parents | 365bc4e2a6a2 (current diff) 84ca744f2f06 (diff) |
children | ff94538090bc |
files | TODO.md |
diffstat | 4 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
diff -r 365bc4e2a6a2 -r 997ea308aeca TODO.md --- a/TODO.md Mon Mar 14 10:51:15 2022 +0100 +++ b/TODO.md Mon Mar 14 15:53:11 2022 +0100 @@ -7,7 +7,6 @@ ## Coding - [ ] Add new Laplace operator to DiffOps, probably named WaveEqOp(?!!?) - [ ] Create a struct that bundles the necessary Tensor operators for solving the wave equation. - - [ ] Add a quick and simple way of running all tests for all subpackages. - [ ] Replace getindex hack for flattening tuples with flatten_tuple. (eg. `getindex.(range_size.(L.D2),1)`) - [ ] Use `@inferred` in a lot of tests. - [ ] Make sure we are setting tolerances in tests in a consistent way
diff -r 365bc4e2a6a2 -r 997ea308aeca src/LazyTensors/LazyTensors.jl --- a/src/LazyTensors/LazyTensors.jl Mon Mar 14 10:51:15 2022 +0100 +++ b/src/LazyTensors/LazyTensors.jl Mon Mar 14 15:53:11 2022 +0100 @@ -1,5 +1,5 @@ module LazyTensors -using Sbplib.RegionIndices + include("tensor_mapping.jl") include("lazy_array.jl") include("lazy_tensor_operations.jl")
diff -r 365bc4e2a6a2 -r 997ea308aeca src/LazyTensors/lazy_tensor_operations.jl --- a/src/LazyTensors/lazy_tensor_operations.jl Mon Mar 14 10:51:15 2022 +0100 +++ b/src/LazyTensors/lazy_tensor_operations.jl Mon Mar 14 15:53:11 2022 +0100 @@ -15,6 +15,7 @@ export LazyTensorMappingApplication Base.getindex(ta::LazyTensorMappingApplication{T,R}, I::Vararg{Any,R}) where {T,R} = apply(ta.t, ta.o, I...) +Base.getindex(ta::LazyTensorMappingApplication{T,1}, I::CartesianIndex{1}) where {T} = apply(ta.t, ta.o, I.I...) # Would otherwise be caught in the previous method. Base.size(ta::LazyTensorMappingApplication) = range_size(ta.t) # TODO: What else is needed to implement the AbstractArray interface?
diff -r 365bc4e2a6a2 -r 997ea308aeca test/LazyTensors/lazy_tensor_operations_test.jl --- a/test/LazyTensors/lazy_tensor_operations_test.jl Mon Mar 14 10:51:15 2022 +0100 +++ b/test/LazyTensors/lazy_tensor_operations_test.jl Mon Mar 14 15:53:11 2022 +0100 @@ -47,6 +47,9 @@ @test_broken BoundsError == (m*m*v)[7] @test_throws MethodError m*m + @test (m*v)[CartesianIndex(2)] == (:apply,v,(2,)) + @test (m*m*v)[CartesianIndex(2)] == (:apply,m*v,(2,)) + m = SizeDoublingMapping{Int, 2, 1}((3,)) @test_throws MethodError m*ones(Int,2,2) @test_throws MethodError m*m*v @@ -56,6 +59,9 @@ @test size(m*v) == 2 .*size(v) @test (m*v)[1,2] == (:apply,v,(1,2)) + @test (m*v)[CartesianIndex(2,3)] == (:apply,v,(2,3)) + @test (m*m*v)[CartesianIndex(4,3)] == (:apply,m*v,(4,3)) + struct ScalingOperator{T,D} <: TensorMapping{T,D,D} λ::T size::NTuple{D,Int}