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 <[email protected]> and contributors"]
version = "0.1.15"
version = "0.1.16"

[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"
NamedDimsArrays = "0.4.5"
SparseArraysBase = "0.2.11"
UnallocatedArrays = "0.1.1"
UnspecifiedTypes = "0.1.1"
Expand Down
5 changes: 5 additions & 0 deletions src/abstractitensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ end
mutable struct ITensor <: AbstractITensor
parent::AbstractArray
nameddimsindices
function ITensor(parent::AbstractArray, dims)
# This checks the shapes of the inputs.
nameddimsindices = NamedDimsArrays.to_nameddimsindices(parent, dims)
return new(parent, nameddimsindices)
end
end
Base.parent(a::ITensor) = a.parent
NamedDimsArrays.nameddimsindices(a::ITensor) = a.nameddimsindices
Expand Down
8 changes: 6 additions & 2 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ using ITensorBase:
using NamedDimsArrays: dename, name, named
using SparseArraysBase: oneelement
using SymmetrySectors: U1
using Test: @test, @test_broken, @testset
using Test: @test, @test_broken, @test_throws, @testset

@testset "ITensorBase" begin
@testset "Basics" begin
elt = Float64
i, j = Index.((2, 2))
x = randn(2, 2)
x = randn(elt, 2, 2)
for a in (ITensor(x, i, j), ITensor(x, (i, j)))
@test dename(a) == x
@test plev(i) == 0
Expand All @@ -34,6 +35,9 @@ using Test: @test, @test_broken, @testset
@test issetequal(inds(a′), (prime(i), prime(j)))
end

@test_throws ErrorException ITensor(randn(elt, 2, 2), Index.((2, 3)))
@test_throws ErrorException ITensor(randn(elt, 4), Index.((2, 2)))

i = Index(2)
i = settag(i, "X", "x")
@test hastag(i, "X")
Expand Down
Loading