Skip to content

Commit 4101429

Browse files
authored
Fix BroadcastStyle for FillArrays (#215)
* Fix `BroadcastStyle` for `FillArrays` types * Version update to v0.15.6
1 parent bce5c92 commit 4101429

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
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.5"
3+
version = "0.15.6"
44

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

src/infarrays.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ end
167167
# Lazy Broadcasting
168168
for typ in (:Ones, :Zeros, :Fill)
169169
@eval begin
170-
BroadcastStyle(::Type{$typ{T,N,NTuple{N,<:OneToInf}}}) where {T,N} = LazyArrayStyle{N}()
171-
BroadcastStyle(::Type{$typ{T,2,<:Tuple{<:Any,<:OneToInf}}}) where {T} = LazyArrayStyle{2}()
172-
BroadcastStyle(::Type{$typ{T,2,<:Tuple{<:OneToInf,<:Any}}}) where {T} = LazyArrayStyle{2}()
170+
BroadcastStyle(::Type{<:$typ{T,N,<:Tuple{OneToInf, Vararg{OneToInf}}}}) where {T,N} = LazyArrayStyle{N}()
171+
BroadcastStyle(::Type{<:$typ{T,2,<:Tuple{Any,OneToInf}}}) where {T} = LazyArrayStyle{2}()
172+
BroadcastStyle(::Type{<:$typ{T,2,<:Tuple{OneToInf,Any}}}) where {T} = LazyArrayStyle{2}()
173+
BroadcastStyle(::Type{<:$typ{T,2,<:Tuple{OneToInf,OneToInf}}}) where {T} = LazyArrayStyle{2}()
173174
end
174175
end
175176

@@ -430,4 +431,4 @@ LazyArrays.cache_getindex(::InfiniteCardinal{0}, A::AbstractVector, I, J...) = l
430431
LazyArrays.cache_getindex(::InfiniteCardinal{0}, A::CachedVector{<:Any,<:AbstractVector,<:AbstractFill{<:Any,1}}, I::AbstractVector) = LazyArrays.cache_getindex(nothing, A, I)
431432

432433

433-
*(a::AbstractVector, b::AbstractFill{<:Any,2,Tuple{OneTo{Int},OneToInf{Int}}}) = ApplyArray(*,a,b)
434+
*(a::AbstractVector, b::AbstractFill{<:Any,2,Tuple{OneTo{Int},OneToInf{Int}}}) = ApplyArray(*,a,b)

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,13 @@ end
884884
@test broadcast(*, 1:∞, Fill(2,∞)') isa BroadcastArray
885885
@test broadcast(*, Diagonal(1:∞), Ones{Int}(∞)') broadcast(*, Ones{Int}(∞)', Diagonal(1:∞)) Diagonal(1:∞)
886886
@test broadcast(*, Diagonal(1:∞), Fill(2,∞)') broadcast(*, Fill(2,∞)', Diagonal(1:∞)) Diagonal(2:2:∞)
887+
888+
@test !(Broadcast.BroadcastStyle(typeof(Fill(4))) isa LazyArrayStyle)
889+
@test Broadcast.BroadcastStyle(typeof(Fill(4, ∞))) isa LazyArrayStyle{1}
890+
@test Broadcast.BroadcastStyle(typeof(Fill(4, ∞, ∞))) isa LazyArrayStyle{2}
891+
@test Broadcast.BroadcastStyle(typeof(Fill(4, ∞, 1))) isa LazyArrayStyle{2}
892+
@test Broadcast.BroadcastStyle(typeof(Fill(4, 1, ∞))) isa LazyArrayStyle{2}
893+
@test Broadcast.BroadcastStyle(typeof(Fill(4, ∞, ∞, ∞))) isa LazyArrayStyle{3}
887894
end
888895

889896
@testset "subview inf broadcast" begin

0 commit comments

Comments
 (0)