Skip to content

Commit 60626ae

Browse files
committed
Fix bug in PermutedDimsArray copy
1 parent bba49b3 commit 60626ae

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

NDTensors/src/lib/BlockSparseArrays/src/blocksparsearrayinterface/blocksparsearrayinterface.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ end
143143
using ..SparseArrayInterface:
144144
SparseArrayInterface, AbstractSparseArray, AbstractSparseMatrix
145145

146-
_perm(::PermutedDimsArray{<:Any,<:Any,P}) where {P} = P
146+
_perm(::PermutedDimsArray{<:Any,<:Any,perm}) where {perm} = perm
147+
_invperm(::PermutedDimsArray{<:Any,<:Any,<:Any,invperm}) where {invperm} = invperm
147148
_getindices(t::Tuple, indices) = map(i -> t[i], indices)
148149
_getindices(i::CartesianIndex, indices) = CartesianIndex(_getindices(Tuple(i), indices))
149150

@@ -164,7 +165,7 @@ function Base.getindex(
164165
a::SparsePermutedDimsArrayBlocks{<:Any,N}, index::Vararg{Int,N}
165166
) where {N}
166167
return PermutedDimsArray(
167-
blocks(parent(a.array))[_getindices(index, _perm(a.array))...], _perm(a.array)
168+
blocks(parent(a.array))[_getindices(index, _invperm(a.array))...], _perm(a.array)
168169
)
169170
end
170171
function SparseArrayInterface.stored_indices(a::SparsePermutedDimsArrayBlocks)

0 commit comments

Comments
 (0)