Mercurial > repos > public > sbplib_julia
changeset 2050:d864282687a7 bugfix/zero_dim_grid_boundary_ops tip
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Thu, 05 Feb 2026 23:23:14 +0100 |
| parents | 8ee4b491c237 (current diff) 2f23d1ef6e1c (diff) |
| children | |
| files | |
| diffstat | 2 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/grid.jl Thu Feb 05 22:33:13 2026 +0100 +++ b/src/Grids/grid.jl Thu Feb 05 23:23:14 2026 +0100 @@ -74,13 +74,13 @@ end end -_array_type(v::ArrayComponentView) = typeof(v) +_array_type(v::ArrayComponentView) = _array_type(typeof(v)) _array_type(::Type{ArrayComponentView{CT,T,D,AT,IT}}) where {CT,T,D,AT,IT} = AT Base.size(cv::ArrayComponentView) = size(cv.v) Base.getindex(cv::ArrayComponentView, i::Int) = cv.v[i][cv.component_index...] Base.getindex(cv::ArrayComponentView, I::Vararg{Int}) = cv.v[I...][cv.component_index...] -Base.IndexStyle(ACT::Type{ArrayComponentView}) = IndexStyle(_array_type(ACT)) +Base.IndexStyle(ACT::Type{<:ArrayComponentView}) = IndexStyle(_array_type(ACT)) # TODO: Implement `setindex!`? # TODO: Implement a more general ComponentView that can handle non-AbstractArrays.
--- a/test/Grids/grid_test.jl Thu Feb 05 22:33:13 2026 +0100 +++ b/test/Grids/grid_test.jl Thu Feb 05 23:23:14 2026 +0100 @@ -114,6 +114,27 @@ @test ArrayComponentView(v, (1:2, 1:2)) == [@SMatrix[1 4;2 5] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] @test ArrayComponentView(v, (2:3, 1:2)) == [@SMatrix[2 5;3 6] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] end + + @testset "size" begin + v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + cv = ArrayComponentView(v, (1, 1)) + + @test size(cv) == (3,4) + end + + @testset "IndexStyle" begin + v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + cv = ArrayComponentView(v, (1, 1)) + + @test IndexStyle(cv) == IndexStyle(v) + end + + @testset "_array_type" begin + v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + cv = ArrayComponentView(v, (1, 1)) + + @test Grids._array_type(cv) == typeof(v) + end end @testset "_ncomponents" begin
