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

Fix searchsorted for new LazyArrays vcat specialised #58

Merged
merged 3 commits into from
Jan 27, 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
4 changes: 2 additions & 2 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.9.0"
version = "0.9.1"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand All @@ -14,7 +14,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
ArrayLayouts = "0.5"
DSP = "0.6"
FillArrays = "0.11"
LazyArrays = "0.20"
LazyArrays = "0.20.2"
julia = "1.5"

[extras]
Expand Down
9 changes: 9 additions & 0 deletions src/InfiniteArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ function searchsortedlast(v::AbstractVector, x, lo::Int, hi::Infinity, o::Orderi
return lo
end

# special case for Vcat
@inline function LazyArrays.searchsortedlast_recursive(::Infinity, x, a, args...)
n = sum(map(length,args))
r = searchsortedlast(a, x)
r > 0 && return n + r
return LazyArrays.searchsortedlast_recursive(n, x, args...)
end


##
# lazy sub_materialize
##
Expand Down
9 changes: 8 additions & 1 deletion src/reshapedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ BroadcastStyle(::Type{<:ReshapedArray{T,2,<:Any,<:Tuple{<:Any,<:Infinity}}}) whe
BroadcastStyle(::Type{<:ReshapedArray{T,2,<:Any,<:Tuple{<:Infinity,<:Any}}}) where {T} = LazyArrayStyle{2}()


MemoryLayout(::Type{<:ReshapedArray{T,N,A,DIMS}}) where {T,N,A,DIMS} = reshapedlayout(MemoryLayout(A), DIMS)
MemoryLayout(::Type{<:ReshapedArray{T,N,A,DIMS}}) where {T,N,A,DIMS} = reshapedlayout(MemoryLayout(A), DIMS)


###
# permutedims for reshaped unrolls
###

permutedims(R::ReshapedArray{<:Any,2,<:AbstractVector}) = parent(R)
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ end
@test permutedims(1:∞)[1,1:10] == (1:10)
a = reshape(Vcat(Fill(1,1,∞),Fill(2,2,∞)),∞)
@test a[1:7] == [1, 2, 2, 1, 2, 2, 1]
@test permutedims(permutedims(1:∞)) ≡ 1:∞
end

@testset "norm/dot" begin
Expand Down