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
7 changes: 2 additions & 5 deletions src/index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ associated with an index, i.e. the index leg is directed into or out of a given
Reverse direction of a directed `Arrow`. Will throw an error for an input of `Neither`.
"""
function -(dir::Arrow)
if dir==Neither
error("Cannot reverse direction of Arrow direction 'Neither'")
else
return dir==In ? Out : In
end
dir==Neither && throw(ArgumentError("Cannot reverse direction of Arrow direction 'Neither'"))
return dir==In ? Out : In
end

"""
Expand Down
5 changes: 5 additions & 0 deletions test/test_index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ITensors: In,Out,Neither
@test id(i) == 0
@test dim(i) == 1
@test dir(i) == Neither
@test_throws ArgumentError -dir(i)
@test plev(i) == 0
@test tags(i) == TagSet("0")
end
Expand Down Expand Up @@ -46,6 +47,8 @@ import ITensors: In,Out,Neither
@test plev(i2) == 2
i3 = i'''
@test plev(i3) == 3
i0 = noprime(i)
@test plev(i0) == 0
end
@testset "IndexVal" begin
i = Index(2)
Expand All @@ -59,5 +62,7 @@ import ITensors: In,Out,Neither
@test plev(i(2)') == 1
@test val(i(2)') == 2
@test plev(prime(i(2),4)) == 4
@test i[:] == [i(1); i(2)]
@test sprint(show, i(2)) == sprint(show, i)*"=2"
end
end