Skip to content

Commit 6f17425

Browse files
authored
Partial support for indexing infinite padded arrays (#222)
* PAatial support for indexing infinite padded arrays * v0.15.8
1 parent 41cc9c5 commit 6f17425

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InfiniteArrays"
22
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
3-
version = "0.15.7"
3+
version = "0.15.8"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/infarrays.jl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,23 +382,26 @@ ArrayLayouts.typed_vcat(::Type{T}, ::Tuple{Any,InfiniteCardinal{0}}, A...) where
382382

383383
sub_materialize(_, V, ::Tuple{InfAxes}) = V
384384
sub_materialize(_, V, ::Tuple{InfAxes,InfAxes}) = V
385-
sub_materialize(_, V, ::Tuple{<:Any,InfAxes}) = V
385+
sub_materialize(_, V, ::Tuple{Any,InfAxes}) = V
386386
sub_materialize(_, V, ::Tuple{InfAxes,Any}) = V
387387

388388

389389
sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractVector, ::Tuple{InfAxes}) = ApplyArray(V)
390-
sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes,InfAxes}) = ApplyArray(V)
391-
sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{<:Any,InfAxes}) = ApplyArray(V)
392-
sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes,Any}) = ApplyArray(V)
390+
sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes, InfAxes}) = ApplyArray(V)
391+
sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{Any, InfAxes}) = ApplyArray(V)
392+
sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes, Any}) = ApplyArray(V)
393393

394394
sub_materialize(::ApplyLayout{typeof(hcat)}, V, ::Tuple{InfAxes}) = V
395-
sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes,InfAxes}) = ApplyArray(V)
396-
sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{<:Any,InfAxes}) = ApplyArray(V)
397-
sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes,Any}) = ApplyArray(V)
395+
sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes, InfAxes}) = ApplyArray(V)
396+
sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{Any, InfAxes}) = ApplyArray(V)
397+
sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes, Any}) = ApplyArray(V)
398398

399399

400-
sub_materialize(::AbstractPaddedLayout, v::AbstractVector{T}, ::Tuple{InfAxes}) where T =
401-
_padded_sub_materialize(v)
400+
sub_materialize(::AbstractPaddedLayout, v::AbstractVector, ::Tuple{InfAxes}) = _padded_sub_materialize(v)
401+
402+
sub_materialize(::AbstractPaddedLayout, v::AbstractMatrix, ::Tuple{InfAxes, InfAxes}) = v
403+
sub_materialize(::AbstractPaddedLayout, v::AbstractMatrix, ::Tuple{InfAxes, Any}) = v
404+
sub_materialize(::AbstractPaddedLayout, v::AbstractMatrix, ::Tuple{Any, InfAxes}) = v
402405

403406
sub_materialize(lay::InvColumnLayout, v::AbstractVector, ax::Tuple{InfAxes}) =
404407
Base.invoke(sub_materialize, Tuple{InvColumnLayout, AbstractVector, Any}, lay, v, ax)

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,16 @@ end
12471247
@test LazyArrays.sub_materialize(view(v, 2:∞))[1:10] == zeros(10)
12481248
@test v[2:∞] isa Zeros
12491249
@test v[1:∞] == v
1250+
1251+
V = Vcat([1 2; 3 4], Zeros(∞,2))
1252+
H = Hcat([1 2; 3 4], Zeros(2,∞))
1253+
S = ApplyArray(Base.setindex, Zeros(∞,∞), [1 2; 3 4], Base.OneTo(2), Base.OneTo(2))
1254+
@test_skip V[:,1] == S[:,1] == [1; 3; Zeros(∞)]
1255+
@test V[:,1] S[:,1] [1; 3; Zeros(∞)] # TODO: change to ==
1256+
@test V[2:∞,1:2] S[2:∞,1:2] Vcat([3 4], Zeros(∞,2))
1257+
@test H[1,:] S[1,:] [1; 2; Zeros(∞)]
1258+
@test_broken H[1:2,2:∞] S[1:2,2:∞] Hcat([2; 4], Zeros(2,∞))
1259+
@test_broken S[2:∞,2:∞] ApplyArray(Base.setindex, Zeros(∞,∞), 4, 1, 1)
12501260
end
12511261

12521262
@testset "issue #180" begin

0 commit comments

Comments
 (0)