Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ITensorBase"
uuid = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
authors = ["ITensor developers <support@itensor.org> and contributors"]
version = "0.1.18"
version = "0.1.19"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down Expand Up @@ -32,7 +32,7 @@ FillArrays = "1.13.0"
GradedUnitRanges = "0.1.4"
LinearAlgebra = "1.10"
MapBroadcast = "0.1.5"
NamedDimsArrays = "0.4.5"
NamedDimsArrays = "0.5.0"
SparseArraysBase = "0.2.11"
UnallocatedArrays = "0.1.1"
UnspecifiedTypes = "0.1.1"
Expand Down
5 changes: 3 additions & 2 deletions src/abstractitensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ mutable struct ITensor <: AbstractITensor
return new(parent, nameddimsindices)
end
end
Base.parent(a::ITensor) = a.parent
NamedDimsArrays.nameddimsindices(a::ITensor) = a.nameddimsindices
Base.parent(a::ITensor) = getfield(a, :parent)
NamedDimsArrays.nameddimsindices(a::ITensor) = getfield(a, :nameddimsindices)
NamedDimsArrays.dename(a::ITensor) = parent(a)

function ITensor(parent::AbstractArray, i1::Index, i_rest::Index...)
return ITensor(parent, (i1, i_rest...))
Expand Down
23 changes: 23 additions & 0 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@ using Test: @test, @test_broken, @test_throws, @testset
@test_throws ErrorException ITensor(randn(elt, 2, 2), Index.((2, 3)))
@test_throws ErrorException ITensor(randn(elt, 4), Index.((2, 2)))

i, j = Index.((3, 4))
a = randn(elt, i, j)
a′ = Array(a)
@test eltype(a′) === elt
@test a′ isa Matrix{elt}
@test a′ == dename(a)

i, j = Index.((3, 4))
a = randn(elt, i, j)
for a′ in (Array{Float32}(a), Matrix{Float32}(a))
@test eltype(a′) === Float32
@test a′ isa Matrix{Float32}
@test a′ == Float32.(dename(a))
end

i, j, k = Index.((2, 2, 2))
a = randn(elt, i, j, k)
b = randn(elt, k, i, j)
copyto!(a, b)
@test a == b
@test dename(a) == dename(b, (i, j, k))
@test dename(a) == permutedims(dename(b), (2, 3, 1))

i = Index(2)
@test plev(i) == 0
i = setprime(i, 2)
Expand Down
Loading