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

an infinite view whose indices are infinite views should be lazy broadcasted #63

Merged
merged 2 commits into from
Feb 19, 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
2 changes: 1 addition & 1 deletion 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.0"
version = "0.10.1"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
4 changes: 3 additions & 1 deletion src/infrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ end
BroadcastStyle(::Type{<:InfRanges}) = LazyArrayStyle{1}()
BroadcastStyle(::Type{<:Adjoint{<:Any,<:InfRanges}}) = LazyArrayStyle{2}()
BroadcastStyle(::Type{<:Transpose{<:Any,<:InfRanges}}) = LazyArrayStyle{2}()
BroadcastStyle(::Type{<:SubArray{<:Any,1,<:Any,<:Tuple{InfRanges}}}) = LazyArrayStyle{1}()
const InfSubVector = SubArray{<:Any,1,<:Any,<:Tuple{InfRanges}}
BroadcastStyle(::Type{<:InfSubVector}) = LazyArrayStyle{1}()
BroadcastStyle(::Type{<:SubArray{<:Any,1,<:Any,<:Tuple{InfSubVector}}}) = LazyArrayStyle{1}()

BroadcastStyle(::Type{<:Base.Slice{<:InfRanges}}) = LazyArrayStyle{1}()

Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,17 @@ end
@test view(V,2:∞,[1,2,3]) .+ 1 isa BroadcastMatrix
@test view(V,[1,2,3],2:∞) .+ 1 isa BroadcastMatrix
end

@testset "inf broadcast views" begin
a = BroadcastArray(cos, 1:∞)
r = div.(1:∞, 2) .+ 1
b = SubArray(a, (r,))
@test b[1:6] == a[r[1:6]]
@test_broken Base.BroadcastStyle(typeof(b)) isa LazyArrayStyle
c = SubArray(a, (view(r,2:∞),))
@test c[1:6] == a[r[2:7]]
@test Base.BroadcastStyle(typeof(c)) isa LazyArrayStyle
end
end

@testset "Cumsum and diff" begin
Expand Down