Skip to content

Commit

Permalink
Generalise last for broadcastVector
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Jan 12, 2025
1 parent 97361a4 commit 6eaf7d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lazybroadcasting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ Broadcasted(A::SubArray{<:Any,N,<:BroadcastArray}) where N = broadcasted(A)::Bro
axes(A::BroadcastArray) = axes(broadcasted(A))
size(A::BroadcastArray) = map(length, axes(A))

last(A::BroadcastArray) = A.f(last.(A.args)...)
_broadcast_last(a) = a
_broadcast_last(a::AbstractArray) = last(a)
_broadcast_last(a::Ref) = a[]

Check warning on line 93 in src/lazybroadcasting.jl

View check run for this annotation

Codecov / codecov/patch

src/lazybroadcasting.jl#L93

Added line #L93 was not covered by tests
last(A::BroadcastArray) = A.f(_broadcast_last.(A.args)...)

@propagate_inbounds getindex(A::BroadcastArray{T,N}, kj::Vararg{Int,N}) where {T,N} = convert(T,broadcasted(A)[kj...])::T

Expand Down

0 comments on commit 6eaf7d7

Please sign in to comment.