From 4158746986656706253513ec07e89278362871d5 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Sun, 22 Dec 2024 16:59:02 -0500 Subject: [PATCH] Fix ReshapedArray wrapper --- Project.toml | 2 +- src/wrappers.jl | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index d22082c..fbe9358 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SparseArraysBase" uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208" authors = ["ITensor developers and contributors"] -version = "0.2.1" +version = "0.2.2" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/wrappers.jl b/src/wrappers.jl index 13e6042..937328b 100644 --- a/src/wrappers.jl +++ b/src/wrappers.jl @@ -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