Skip to content

Commit b2889ed

Browse files
authored
Merge pull request #248 from JuliaArrays/broadcastsize
Fix size of broadcast objects
2 parents 3defbb5 + d60c58d commit b2889ed

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "5.0.0"
3+
version = "5.0.1"
44

55
[deps]
66
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

src/size.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ julia> ArrayInterface.size(A)
1717
```
1818
"""
1919
size(a::A) where {A} = _maybe_size(Base.IteratorSize(A), a)
20+
size(a::Base.Broadcast.Broadcasted) = map(static_length, axes(a))
21+
2022
_maybe_size(::Base.HasShape{N}, a::A) where {N,A} = map(static_length, axes(a))
2123
_maybe_size(::Base.HasLength, a::A) where {A} = (static_length(a),)
2224
size(x::SubArray) = eachop(_sub_size, to_parent_dims(x), x.indices)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ ArrayInterface.parent_type(::Type{DenseWrapper{T,N,P}}) where {T,N,P} = P
260260

261261
@testset "Memory Layout" begin
262262
x = zeros(100);
263+
@test ArrayInterface.size(Base.Broadcast.Broadcasted(+, (x, x'))) === (100,100)
263264
# R = reshape(view(x, 1:100), (10,10));
264265
# A = zeros(3,4,5);
265266
A = Wrapper(reshape(view(x, 1:60), (3,4,5)));

0 commit comments

Comments
 (0)