-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples of mortar() for nd arrays? #414
Comments
I suspect the docstring ia out of date or just wrong… since you have an alternative that works is there any reason to want to use mortar? We should probably just delete that docstring. |
The alternative does not work for my use-case, or at least, I don't think so. This is related to #87, where the idea is that I have some images that need to be tiled together with some overlaps, and I want to I'm currently getting around this by making a vector of 2D arrays, one for each layer, but it would be nice to be able to have a 3D blocked array instead. If there's a different way to use the |
I just figured this out! It was a problem of not creating the 3D array in the first step - I didn't realize that part was required (nor, actually, how to do that). Here's an example of what I was trying to do before: julia> m0 = zeros(10, 10, 2); m1 = ones(10, 10, 2);
julia> m0v = @view m0[1:5,1:5,:]; m1v = @view m1[6:10, 6:10,:];
julia> ba = [[[m0v] [m1v]];;;]
1×2×1 Array{SubArray{Float64, 3, Array{Float64, 3}, Tuple{UnitRange{Int64}, UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, 3}:
[:, :, 1] =
[0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0;;; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0] … [1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0]
julia> ma = mortar(ba)
1×2×1-blocked 5×10×2 BlockArray{Float64, 3, Array{SubArray{Float64, 3, Array{Float64, 3}, Tuple{UnitRange{Int64}, UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, 3}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}}:
[:, :, 1] =
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
[:, :, 2] =
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
julia> m1[:,:,2] .= 2; ma
1×2×1-blocked 5×10×2 BlockArray{Float64, 3, Array{SubArray{Float64, 3, Array{Float64, 3}, Tuple{UnitRange{Int64}, UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, 3}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}}:
[:, :, 1] =
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0
[:, :, 2] =
0.0 0.0 0.0 0.0 0.0 2.0 2.0 2.0 2.0 2.0
0.0 0.0 0.0 0.0 0.0 2.0 2.0 2.0 2.0 2.0
0.0 0.0 0.0 0.0 0.0 2.0 2.0 2.0 2.0 2.0
0.0 0.0 0.0 0.0 0.0 2.0 2.0 2.0 2.0 2.0
0.0 0.0 0.0 0.0 0.0 2.0 2.0 2.0 2.0 2.0 |
The docstring for
mortar()
showsBut I can't figure out how to use this. Here's what I expected to work:
I was expecting this to produce the equivalent of
The text was updated successfully, but these errors were encountered: