Skip to content

Commit 3dd4b0c

Browse files
committed
improve real(::MPOHamiltonian) coverage
1 parent 5558e49 commit 3dd4b0c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/operators.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module TestOperators
124124
@testset "Finite MPOHamiltonian" begin
125125
L = 3
126126
T = ComplexF64
127-
for V in (ℂ^2, U1Space(-1 => 1, 0 => 1, 1 => 1))
127+
for T in (Float64, ComplexF64), V in (ℂ^2, U1Space(-1 => 1, 0 => 1, 1 => 1))
128128
lattice = fill(V, L)
129129
O₁ = randn(T, V, V)
130130
O₁ += O₁'
@@ -136,6 +136,17 @@ module TestOperators
136136
H2 = FiniteMPOHamiltonian(lattice, (i, i + 1) => O₂ for i in 1:(L - 1))
137137
H3 = FiniteMPOHamiltonian(lattice, 1 => O₁, (2, 3) => O₂, (1, 3) => O₂)
138138

139+
@test scalartype(H1) == scalartype(H2) == scalartype(H3) == T
140+
if !(T <: Complex)
141+
for H in (H1, H2, H3)
142+
Hc = @constinferred complex(H)
143+
@test scalartype(Hc) == complex(T)
144+
Hr = @constinferred real(Hc)
145+
@test scalartype(Hr) == T
146+
@test H Hr atol = 1.0e-6
147+
end
148+
end
149+
139150
# check if constructor works by converting back to tensormap
140151
H1_tm = convert(TensorMap, H1)
141152
operators = vcat(fill(E, L - 1), O₁)

0 commit comments

Comments
 (0)