Skip to content

Make map/broadcast a bit more customizable #152

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

Merged
merged 1 commit into from
Jun 19, 2025
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,7 +1,7 @@
name = "BlockSparseArrays"
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.7.16"
version = "0.7.17"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
4 changes: 2 additions & 2 deletions src/blocksparsearrayinterface/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ function viewblock_stored(a::AbstractArray{<:Any,N}, I::Block{N}) where {N}
return viewblock_stored(a, Tuple(I)...)
end

using FillArrays: Zeros
using FillArrays: Zeros, fillsimilar
# Get a view of a block if it is stored, otherwise return a lazy zeros.
function viewblock_or_zeros(a::AbstractArray{<:Any,N}, I::Vararg{Block{1},N}) where {N}
if isstored(a, I...)
return viewblock_stored(a, I...)
else
block_ax = map((ax, i) -> eachblockaxis(ax)[Int(i)], axes(a), I)
return Zeros{eltype(a)}(block_ax)
return fillsimilar(Zeros{eltype(a)}(block_ax), block_ax)
end
end
function viewblock_or_zeros(a::AbstractArray{<:Any,N}, I::Block{N}) where {N}
Expand Down
Loading