Skip to content

Commit 41d1113

Browse files
committed
mixed type tests for ProjectTo
1 parent c81e43c commit 41d1113

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

test/ad.jl

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,33 @@ Vlist = ((ℂ^2, (ℂ^3)', ℂ^3, ℂ^2, (ℂ^2)'),
148148
end
149149

150150
@timedtestset "Basic utility (DiagonalTensor)" begin
151-
for NumType in [Float64, ComplexF64]
152-
for v in V
153-
T1 = DiagonalTensorMap(randn(NumType, dim(v)), v)
154-
T2 = TensorMap(T1)
155-
156-
P1 = ProjectTo(T1)
157-
@test P1(T2) == T1
158-
159-
test_rrule(DiagonalTensorMap, T1.data, T1.domain)
160-
end
151+
for v in V
152+
D1 = DiagonalTensorMap(randn(dim(v)), v)
153+
D2 = DiagonalTensorMap(randn(dim(v)), v)
154+
D = D1 + im * D2
155+
T1 = TensorMap(D1)
156+
T2 = TensorMap(D2)
157+
T = T1 + im * T2
158+
159+
# real -> real
160+
P1 = ProjectTo(D1)
161+
@test P1(D1) == D1
162+
@test P1(T1) == D1
163+
164+
# complex -> complex
165+
P2 = ProjectTo(D)
166+
@test P2(D) == D
167+
@test P2(T) == D
168+
169+
# real -> complex
170+
@test P2(D1) == D1 + 0 * im * D1
171+
@test P2(T1) == D1 + 0 * im * D1
172+
173+
# complex -> real
174+
@test P1(D) == D1
175+
@test P1(T) == D1
176+
177+
test_rrule(DiagonalTensorMap, D1.data, D1.domain)
161178
end
162179
end
163180

0 commit comments

Comments
 (0)