Skip to content
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

LazyArrays v0.21 #65

Merged
merged 4 commits into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InfiniteArrays"
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
version = "0.10.2"
version = "0.10.3"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand All @@ -12,11 +12,11 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
ArrayLayouts = "0.5, 0.6"
ArrayLayouts = "0.6"
DSP = "0.6"
FillArrays = "0.11"
Infinities = "0.0.2"
LazyArrays = "0.20.5"
LazyArrays = "0.21.1"
julia = "1.5"

[extras]
Expand Down
10 changes: 7 additions & 3 deletions src/infarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ _unsafe_getindex(::IndexLinear, A::Vcat, r::InfUnitRange) = _vcat(_gettail(first

getindex(A::AbstractVector, r::InfRanges{<:Integer}) = layout_getindex(A, r)
getindex(A::LayoutVector, r::InfRanges{<:Integer}) = layout_getindex(A, r)
getindex(A::AbstractCachedVector, r::InfRanges{<:Integer}) = layout_getindex(A, r)
getindex(A::CachedVector{<:Any,<:AbstractVector,<:AbstractFill{<:Any,1}}, r::InfRanges{<:Integer}) = layout_getindex(A, r)
getindex(A::AbstractFill{<:Any,1}, r::InfRanges{<:Integer}) = FillArrays.fillsimilar(A, length(r))
getindex(A::CachedVector, r::InfRanges{<:Integer}) = layout_getindex(A, r)
getindex(A::AbstractFill{<:Any,1}, r::InfRanges{<:Integer}) = FillArrays.fillsimilar(A, length(r))


Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, I::AbstractFill) = Base.checkindex(Bool, inds, getindex_value(I))
LazyArrays.cache_getindex(::InfiniteCardinal{0}, A::AbstractVector, I, J...) = layout_getindex(A, I, J...)

5 changes: 4 additions & 1 deletion src/infrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,7 @@ for op in (:isequal, :(==))
findfirst(p::Fix2{typeof($op),<:Number}, r::InfStepRange{<:Integer,<:Integer}) =
isinteger(p.x) ? findfirst($op(convert(V, p.x)), r) : nothing
end
end
end


FillArrays._range_convert(::Type{AbstractVector{T}}, r::InfRanges) where T = convert(AbstractVector{T}, r)
23 changes: 23 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate

@test similar(a, Float64, (2,∞)) isa CachedArray{Float64}
@test similar(a, Float64, (∞,2)) isa CachedArray{Float64}

@test similar(Array{Float64}, (∞,)) isa CachedArray{Float64}
@test similar(Array{Float64}, (∞,∞)) isa CachedArray{Float64}
@test similar(Array{Float64}, (2,∞)) isa CachedArray{Float64}
@test similar(Array{Float64}, (∞,2)) isa CachedArray{Float64}

@test similar(Array{Float64}, (oneto(∞),)) isa CachedArray{Float64}
@test similar(Array{Float64}, (oneto(∞),oneto(∞))) isa CachedArray{Float64}
@test similar(Array{Float64}, (oneto(∞),oneto(5))) isa CachedArray{Float64}
@test similar(Array{Float64}, (oneto(5),oneto(∞))) isa CachedArray{Float64}
end

@testset "zeros/fill/ones" begin
Expand Down Expand Up @@ -83,6 +91,10 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate
@test ones(5,∞)[:,1:10] == ones(5,10)
@test ones(∞,5)[1:10,:] == ones(10,5)
@test ones(∞,∞)[1:5,1:5] == ones(5,5)

@test zeros(∞, 5)[1:10,:] == zeros(10,5)
@test zeros(Int, ∞, 5)[1:10,:] == zeros(10,5)
@test zeros(Int, 5, ∞)[:,1:10] == zeros(5, 10)
end
end

Expand Down Expand Up @@ -490,6 +502,13 @@ end
@test @inferred(broadcast(*,Ones(∞)',D)) == @inferred(broadcast(*,D,Ones(∞)')) == Diagonal(1.0:∞)
@test @inferred(broadcast(*,Fill(2,∞)',D)) ≡ @inferred(broadcast(*,D,Fill(2,∞)')) ≡ 2D

@test Eye{Int}(∞, ∞) isa Eye{Int}
@test Eye{Int}(∞, 5) isa Eye{Int}
@test Eye{Int}(5, ∞) isa Eye{Int}
@test Eye(∞, ∞) isa Eye{Float64}
@test Eye(∞, 5) isa Eye{Float64}
@test Eye(5, ∞) isa Eye{Float64}

@test Eye{Int}(∞) * D ≡ Eye{Int}(∞) * D ≡ D
@test Eye(∞) * D == Eye(∞) * D == D
end
Expand Down Expand Up @@ -893,4 +912,8 @@ end
AbstractMatrix{Float64}(transpose(1:∞)) ≡ AbstractMatrix{Float64}(transpose(oneto(∞))) ≡
AbstractArray{Float64}(transpose(1:∞)) ≡ AbstractArray{Float64}(transpose(oneto(∞))) ≡
transpose(InfUnitRange(1.0))
end

@testset "cached indexing" begin
@test cache(1:∞)[Fill(2,∞)][1:10] == fill(2,10)
end