Skip to content

Commit

Permalink
Revert changes to ITensorsNamedDimsArraysExt
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Nov 12, 2024
1 parent a48f7e7 commit 4c322e4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/lib/ITensorsNamedDimsArraysExt/src/to_nameddimsarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ function to_nameddimsarray(x::DiagTensor)
return named(DiagonalArray(data(x), size(x)), name.(inds(x)))
end

using ..NDTensors.BlockSparseArrays.BlockArrays: BlockArrays, blockedrange
using ..NDTensors: BlockSparseTensor, array, blockdim, datatype, nblocks, nzblocks
using ..NDTensors: BlockSparseTensor
using ..NDTensors.BlockSparseArrays: BlockSparseArray
using ..NDTensors.TypeParameterAccessors: set_ndims
# TODO: Delete once `BlockSparse` is removed.
function to_nameddimsarray(x::BlockSparseTensor)
blockinds = map(i -> blockedrange([blockdim(i, b) for b in 1:nblocks(i)]), inds(x))
blockinds = map(i -> [blockdim(i, b) for b in 1:nblocks(i)], inds(x))
blocktype = set_ndims(datatype(x), ndims(x))
# TODO: Make a simpler constructor:
# BlockSparseArray(blocktype, blockinds)
arraystorage = BlockSparseArray{eltype(x),ndims(x),blocktype}(undef, blockinds)
arraystorage = BlockSparseArray{eltype(x),ndims(x),blocktype}(blockinds)
for b in nzblocks(x)
arraystorage[BlockArrays.Block(Int.(Tuple(b))...)] = array(x[b])
arraystorage[BlockArrays.Block(Tuple(b)...)] = x[b]
end
return named(arraystorage, name.(inds(x)))
end
Expand Down

0 comments on commit 4c322e4

Please sign in to comment.