Skip to content

Commit

Permalink
Fix ReshapedArray wrapper (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman authored Dec 22, 2024
1 parent e112a01 commit 13b38d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SparseArraysBase"
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.2.1"
version = "0.2.2"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
10 changes: 8 additions & 2 deletions src/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ function parentindex_to_index(a::PermutedDimsArray{<:Any,N}, I::CartesianIndex{N
end

using Base: ReshapedArray
function parentindex_to_index(a::ReshapedArray{<:Any,N}, I::CartesianIndex{N}) where {N}
# Don't constrain the number of dimensions of the array
# and index since the parent array can have a different
# number of dimensions than the `SubArray`.
function parentindex_to_index(a::ReshapedArray, I::CartesianIndex)
return CartesianIndices(size(a))[LinearIndices(parent(a))[I]]
end
function index_to_parentindex(a::ReshapedArray{<:Any,N}, I::CartesianIndex{N}) where {N}
# Don't constrain the number of dimensions of the array
# and index since the parent array can have a different
# number of dimensions than the `SubArray`.
function index_to_parentindex(a::ReshapedArray, I::CartesianIndex)
return CartesianIndices(parent(a))[LinearIndices(size(a))[I]]
end

Expand Down

0 comments on commit 13b38d0

Please sign in to comment.