Skip to content
Open
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
11 changes: 8 additions & 3 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,20 @@ function common_chunks(s, args...)
all(ar -> isa(eachchunk(ar), GridChunks), chunkedarrays) ||
error("Currently only chunks of type GridChunks can be merged by broadcast")
if isempty(chunkedarrays)
totalsize = sum(sizeof ∘ eltype, args)
return estimate_chunksize(s, totalsize)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function does actually the wrong thing. Can we just call into this method

estimate_chunksize(a::AbstractArray) = estimate_chunksize(size(a), element_size(a))
and have the non-isbits types covered?

# Estimate chunk size for isbits
if all(map(isbits ∘ eltype, args))
totalsize = sum(sizeof ∘ eltype, args)
return estimate_chunksize(s, totalsize)
else # Otherwise just use one huge chunk, we dont know what the object is
return GridChunks(s, s)
end
elseif length(chunkedarrays) == 1
return eachchunk(only(chunkedarrays))
else
allchunks = collect(map(eachchunk, chunkedarrays))
tt = ntuple(N) do n
csnow = filter(allchunks) do cs
ndims(cs) >= n && first(first(cs.chunks[n])) < last(last(cs.chunks[n]))
ndims(cs) >= n && first(first(cs.chunks[n])) < last(last(cs.chunks[n]))
end
isempty(csnow) && return RegularChunks(1, 0, s[n])

Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1116,3 +1116,8 @@ end
@inferred DiskArrays.DiskIndex(a_view5, (1:1, 1:1, 1:1, 1:1, 1:1), DiskArrays.NoBatch()) #DiskArrays.DiskIndex
@inferred DiskArrays.DiskIndex(a_view6, (1:1, 1:1, 1:1, 1:1, 1:1, 1:1), DiskArrays.NoBatch()) #DiskArrays.DiskIndex
end

@testset "test broadcast over strings" begin
a = UnchunkedDiskArray(["a", "b", "c"])
@test all(a .== ["a", "b", "c"])
end
Loading