Skip to content

Commit da70733

Browse files
committed
Bump to v0.9
1 parent c3132a7 commit da70733

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
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.8.2"
4+
version = "0.9.0"
55

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

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
66

77
[compat]
88
BlockArrays = "1"
9-
BlockSparseArrays = "0.8"
9+
BlockSparseArrays = "0.9"
1010
Documenter = "1"
1111
Literate = "2"

examples/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
55

66
[compat]
77
BlockArrays = "1"
8-
BlockSparseArrays = "0.8"
8+
BlockSparseArrays = "0.9"
99
Test = "1"

ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,20 @@ function TensorAlgebra.matricize(
2424
)
2525
ax = fuseaxes(axes(a), biperm)
2626
reshaped_blocks_a = reshape(blocks(a), map(blocklength, ax))
27-
bs = Dict(
28-
Block(Tuple(I)) => matricize(reshaped_blocks_a[I], biperm) for
29-
I in eachstoredindex(reshaped_blocks_a)
30-
)
27+
key(I) = Block(Tuple(I))
28+
value(I) = matricize(reshaped_blocks_a[I], biperm)
29+
Is = eachstoredindex(reshaped_blocks_a)
30+
bs = if isempty(Is)
31+
# Catch empty case and make sure the type is constrained properly.
32+
# This seems to only be necessary in Julia versions below v1.11,
33+
# try removing it when we drop support for those versions.
34+
keytype = Base.promote_op(key, eltype(Is))
35+
valtype = Base.promote_op(value, eltype(Is))
36+
valtype′ = !isconcretetype(valtype) ? AbstractMatrix{eltype(a)} : valtype
37+
Dict{keytype,valtype′}()
38+
else
39+
Dict(key(I) => value(I) for I in Is)
40+
end
3141
return blocksparse(bs, ax)
3242
end
3343

src/blocksparsearray/blocksparsearray.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,15 @@ function blocksparsezeros(::BlockType{A}, axes...) where {A<:AbstractArray}
263263
return BlockSparseArray{eltype(A),ndims(A),A}(undef, axes...)
264264
end
265265
function blocksparse(d::Dict, ax::Tuple)
266+
d_narrow = if isempty(d)
267+
Dict{Block{length(ax),Int},AbstractArray{Any,length(ax)}}()
268+
else
269+
Dict(Pair(kv) for kv in d)
270+
end
271+
return blocksparse(d_narrow, ax)
272+
end
273+
function blocksparse(d::Dict{<:Block{N},<:AbstractArray{<:Any,N}}, ax::Tuple) where {N}
266274
a = blocksparsezeros(BlockType(valtype(d)), ax...)
267-
268-
## blockaxtype = Tuple{map(eltype ∘ eachblockaxis, ax)...}
269-
## # TODO: Catch if inference fails and use `valtype(d)` instead.
270-
## blockt = Base.promote_op(similar, Type{valtype(d)}, blockaxtype)
271-
## a = blocksparsezeros(BlockType(blockt), ax)
272-
273275
for I in eachindex(d)
274276
a[I] = d[I]
275277
end

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Adapt = "4"
2525
Aqua = "0.8"
2626
ArrayLayouts = "1"
2727
BlockArrays = "1"
28-
BlockSparseArrays = "0.8"
28+
BlockSparseArrays = "0.9"
2929
DerivableInterfaces = "0.5"
3030
DiagonalArrays = "0.3"
3131
GPUArraysCore = "0.2"

0 commit comments

Comments
 (0)