Skip to content

Commit ad99db2

Browse files
authored
Update to NamedDimsArrays.jl v0.5 (#36)
1 parent a872b48 commit ad99db2

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ITensorBase"
22
uuid = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.1.18"
4+
version = "0.1.19"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
@@ -32,7 +32,7 @@ FillArrays = "1.13.0"
3232
GradedUnitRanges = "0.1.4"
3333
LinearAlgebra = "1.10"
3434
MapBroadcast = "0.1.5"
35-
NamedDimsArrays = "0.4.5"
35+
NamedDimsArrays = "0.5.0"
3636
SparseArraysBase = "0.2.11"
3737
UnallocatedArrays = "0.1.1"
3838
UnspecifiedTypes = "0.1.1"

src/abstractitensor.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ mutable struct ITensor <: AbstractITensor
8686
return new(parent, nameddimsindices)
8787
end
8888
end
89-
Base.parent(a::ITensor) = a.parent
90-
NamedDimsArrays.nameddimsindices(a::ITensor) = a.nameddimsindices
89+
Base.parent(a::ITensor) = getfield(a, :parent)
90+
NamedDimsArrays.nameddimsindices(a::ITensor) = getfield(a, :nameddimsindices)
91+
NamedDimsArrays.dename(a::ITensor) = parent(a)
9192

9293
function ITensor(parent::AbstractArray, i1::Index, i_rest::Index...)
9394
return ITensor(parent, (i1, i_rest...))

test/test_basics.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ using Test: @test, @test_broken, @test_throws, @testset
3939
@test_throws ErrorException ITensor(randn(elt, 2, 2), Index.((2, 3)))
4040
@test_throws ErrorException ITensor(randn(elt, 4), Index.((2, 2)))
4141

42+
i, j = Index.((3, 4))
43+
a = randn(elt, i, j)
44+
a′ = Array(a)
45+
@test eltype(a′) === elt
46+
@test a′ isa Matrix{elt}
47+
@test a′ == dename(a)
48+
49+
i, j = Index.((3, 4))
50+
a = randn(elt, i, j)
51+
for a′ in (Array{Float32}(a), Matrix{Float32}(a))
52+
@test eltype(a′) === Float32
53+
@test a′ isa Matrix{Float32}
54+
@test a′ == Float32.(dename(a))
55+
end
56+
57+
i, j, k = Index.((2, 2, 2))
58+
a = randn(elt, i, j, k)
59+
b = randn(elt, k, i, j)
60+
copyto!(a, b)
61+
@test a == b
62+
@test dename(a) == dename(b, (i, j, k))
63+
@test dename(a) == permutedims(dename(b), (2, 3, 1))
64+
4265
i = Index(2)
4366
@test plev(i) == 0
4467
i = setprime(i, 2)

0 commit comments

Comments
 (0)