Skip to content

Commit c3359b2

Browse files
authored
Fix for DiskArrays.jl v0.4.13 (#9)
1 parent f28c13b commit c3359b2

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SerializedArrays"
22
uuid = "621c0da3-e96e-4f80-bd06-5ae31cdfcb39"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"

src/SerializedArrays.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export SerializedArray, disk, memory
44

55
using Base.PermutedDimsArrays: genperm
66
using ConstructionBase: constructorof
7-
using DiskArrays: DiskArrays, AbstractDiskArray, Unchunked, readblock!, writeblock!
7+
using DiskArrays:
8+
DiskArrays, AbstractDiskArray, PermutedDiskArray, Unchunked, readblock!, writeblock!
89
using Serialization: deserialize, serialize
910

1011
adapt_serialized(to, x) = adapt_structure_serialized(to, x)
@@ -159,26 +160,31 @@ end
159160
# PermutedSerializedArray
160161
#
161162

162-
struct PermutedSerializedArray{T,N,P<:PermutedDimsArray{T,N}} <:
163+
struct PermutedSerializedArray{T,N,perm,iperm,P<:AbstractArray{T,N}} <:
163164
AbstractSerializedArray{T,N}
164-
permuted_parent::P
165+
parent::P
165166
end
166-
Base.parent(a::PermutedSerializedArray) = parent(getfield(a, :permuted_parent))
167+
Base.parent(a::PermutedSerializedArray) = getfield(a, :parent)
167168

168169
file(a::PermutedSerializedArray) = file(parent(a))
169170

170-
perm(a::PermutedSerializedArray) = perm(a.permuted_parent)
171-
perm(::PermutedDimsArray{<:Any,<:Any,p}) where {p} = p
172-
173-
iperm(a::PermutedSerializedArray) = iperm(a.permuted_parent)
174-
iperm(::PermutedDimsArray{<:Any,<:Any,<:Any,ip}) where {ip} = ip
171+
# TODO: Use `TypeParameterAccessors.jl`.
172+
perm(a::PermutedDimsArray{<:Any,<:Any,p}) where {p} = p
173+
perm(a::PermutedDiskArray{<:Any,<:Any,p}) where {p} = p
174+
perm(a::PermutedSerializedArray{<:Any,<:Any,p}) where {p} = p
175+
# TODO: Use `TypeParameterAccessors.jl`.
176+
iperm(a::PermutedDimsArray{<:Any,<:Any,<:Any,ip}) where {ip} = ip
177+
iperm(a::PermutedDiskArray{<:Any,<:Any,ip}) where {ip} = ip
178+
iperm(a::PermutedSerializedArray{<:Any,<:Any,<:Any,ip}) where {ip} = ip
175179

176180
Base.axes(a::PermutedSerializedArray) = genperm(axes(parent(a)), perm(a))
177-
Base.size(a::PermutedSerializedArray) = length.(axes(a))
181+
Base.size(a::PermutedSerializedArray) = map(length, axes(a))
178182

179-
function PermutedSerializedArray(a::AbstractArray, perm)
180-
a′ = PermutedDimsArray(a, perm)
181-
return PermutedSerializedArray{eltype(a),ndims(a),typeof(a′)}(a′)
183+
function PermutedSerializedArray(a::AbstractArray, p)
184+
# This returns a `PermutedDiskArray` as of:
185+
# https://github.com/JuliaIO/DiskArrays.jl/pull/249
186+
a′ = PermutedDimsArray(a, p)
187+
return PermutedSerializedArray{eltype(a),ndims(a),perm(a′),iperm(a′),typeof(a)}(a)
182188
end
183189

184190
function Base.permutedims(a::AbstractSerializedArray, perm)

0 commit comments

Comments
 (0)