Skip to content

Commit cdf333a

Browse files
committed
More robust blockreshape
1 parent c96c064 commit cdf333a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.9.1"
4+
version = "0.9.2"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/BlockArraysExtensions/BlockArraysExtensions.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ function _blockreshape(a::AbstractArray, axes::Tuple{Vararg{AbstractUnitRange}})
277277
# TODO: Better converter here.
278278
return reshape(reshaped_blocks_a[I], block_axes_I)
279279
end
280-
bs = Dict(Block(Tuple(I)) => f(I) for I in eachstoredindex(reshaped_blocks_a))
280+
bs = if iszero(storedlength(reshaped_blocks_a))
281+
# This branch only seems to be required in Julia 1.10, not Julia 1.11.
282+
# TODO: Remove this branch once Julia 1.10 support is dropped.
283+
Dict{Block{length(axes),Int},AbstractArray{eltype(a),length(axes)}}()
284+
else
285+
Dict(Block(Tuple(I)) => f(I) for I in eachstoredindex(reshaped_blocks_a))
286+
end
281287
return blocksparse(bs, axes)
282288
end
283289

0 commit comments

Comments
 (0)