diff --git a/src/index.jl b/src/index.jl index 99ce8ff75a..795cb147e1 100644 --- a/src/index.jl +++ b/src/index.jl @@ -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 """ diff --git a/test/test_index.jl b/test/test_index.jl index 336f31c26b..be72acbaa8 100644 --- a/test/test_index.jl +++ b/test/test_index.jl @@ -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 @@ -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) @@ -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