Skip to content

Commit ffac196

Browse files
committed
Improve test coverage
1 parent 19a7054 commit ffac196

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/tensors/diagonal.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ Construct a `DiagonalTensorMap` with uninitialized data.
3939
"""
4040
function DiagonalTensorMap{T}(::UndefInitializer, V::TensorMapSpace) where {T}
4141
(numin(V) == numout(V) == 1 && domain(V) == codomain(V)) ||
42-
throw(SpaceMismatch("DiagonalTensorMap requires a space with equal domain and codomain and 2 indices"))
42+
throw(ArgumentError("DiagonalTensorMap requires a space with equal domain and codomain and 2 indices"))
4343
return DiagonalTensorMap{T}(undef, domain(V))
4444
end
4545
function DiagonalTensorMap{T}(::UndefInitializer, V::ProductSpace) where {T}
4646
length(V) == 1 ||
47-
throw(DimensionMismatch("DiagonalTensorMap requires `numin(d) == numout(d) == 1`"))
47+
throw(ArgumentError("DiagonalTensorMap requires `numin(d) == numout(d) == 1`"))
4848
return DiagonalTensorMap{T}(undef, only(V))
4949
end
5050
function DiagonalTensorMap{T}(::UndefInitializer, V::S) where {T,S<:IndexSpace}

test/diagonal.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
55
@testset "DiagonalTensor with domain $V" for V in diagspacelist
66
@timedtestset "Basic properties and algebra" begin
77
for T in (Float32, Float64, ComplexF32, ComplexF64, BigFloat)
8+
# constructors
89
t = @constinferred DiagonalTensorMap{T}(undef, V)
910
t = @constinferred DiagonalTensorMap(rand(T, reduceddim(V)), V)
11+
t2 = @constinferred DiagonalTensorMap{T}(undef, space(t))
12+
@test space(t2) == space(t)
13+
@test_throws ArgumentError DiagonalTensorMap{T}(undef, V^2 V)
14+
t2 = @constinferred DiagonalTensorMap{T}(undef, domain(t))
15+
@test space(t2) == space(t)
16+
@test_throws ArgumentError DiagonalTensorMap{T}(undef, V^2)
17+
# properties
1018
@test @constinferred(hash(t)) == hash(deepcopy(t))
1119
@test scalartype(t) == T
1220
@test codomain(t) == ProductSpace(V)

0 commit comments

Comments
 (0)