Skip to content

Commit 7b713c6

Browse files
authored
fix: storagetypes should promote correctly (#57)
* fix: storagetypes * supply init
1 parent d927cb3 commit 7b713c6

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockTensorKit"
22
uuid = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
3-
version = "0.3.12"
3+
version = "0.3.13"
44
authors = ["Lukas Devos <ldevos98@gmail.com> and contributors"]
55

66
[deps]

‎src/tensors/blocktensor.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Base.parent(t::BlockTensorMap) = t.data
164164
# handle this separately because the storagetype of `AbstractTensorMap` is
165165
# *always* Vector no matter the actual data storage type
166166
TK.storagetype(t::BlockTensorMap{AbstractTensorMap{E, S, N₁, N₂}}) where {E, S, N₁, N₂} =
167-
foldl(TK.promote_storagetype, values(t.data))
167+
mapreduce(TK.storagetype, TK.promote_storagetype, values(t.data); init = TK.storagetype(eltype(t)))
168168

169169
function Base.copyto!(
170170
dest::BlockTensorMap, Rdest::CartesianIndices,

‎src/tensors/sparseblocktensor.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Base.eltype(::Type{<:SparseBlockTensorMap{TT}}) where {TT} = TT
171171
# handle this separately because the storagetype of `AbstractTensorMap` is
172172
# *always* Vector no matter the actual data storage type
173173
TK.storagetype(t::SparseBlockTensorMap{AbstractTensorMap{E, S, N₁, N₂}}) where {E, S, N₁, N₂} =
174-
foldl(TK.promote_storagetype, nonzero_values(t))
174+
mapreduce(TK.storagetype, TK.promote_storagetype, nonzero_values(t); init = TK.storagetype(eltype(t)))
175175

176176
issparse(::SparseBlockTensorMap) = true
177177
nonzero_keys(t::SparseBlockTensorMap) = keys(t.data)

0 commit comments

Comments
 (0)