Skip to content

Commit 13b38d0

Browse files
authored
Fix ReshapedArray wrapper (#11)
1 parent e112a01 commit 13b38d0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseArraysBase"
22
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.1"
4+
version = "0.2.2"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/wrappers.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ function parentindex_to_index(a::PermutedDimsArray{<:Any,N}, I::CartesianIndex{N
5858
end
5959

6060
using Base: ReshapedArray
61-
function parentindex_to_index(a::ReshapedArray{<:Any,N}, I::CartesianIndex{N}) where {N}
61+
# Don't constrain the number of dimensions of the array
62+
# and index since the parent array can have a different
63+
# number of dimensions than the `SubArray`.
64+
function parentindex_to_index(a::ReshapedArray, I::CartesianIndex)
6265
return CartesianIndices(size(a))[LinearIndices(parent(a))[I]]
6366
end
64-
function index_to_parentindex(a::ReshapedArray{<:Any,N}, I::CartesianIndex{N}) where {N}
67+
# Don't constrain the number of dimensions of the array
68+
# and index since the parent array can have a different
69+
# number of dimensions than the `SubArray`.
70+
function index_to_parentindex(a::ReshapedArray, I::CartesianIndex)
6571
return CartesianIndices(parent(a))[LinearIndices(size(a))[I]]
6672
end
6773

0 commit comments

Comments
 (0)