You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following code snippet, the two tensors differ by a phase of 1j. Running this for different seeds, I find that the phase of z is either [1, 1j, -1, -1j].
import numpy as np
import random
import pyzx as zx
random.seed(1)
g1 = zx.generate.cliffordT(3, 20, p_t=0)
g2 = g1.copy()
zx.clifford_simp(g2) # Removing this line makes the assert pass
assert np.allclose(g1.to_tensor(), g2.to_tensor())
z = g1 + g2.adjoint()
zx.clifford_simp(z)
# print(z.to_tensor())
assert z.is_id()
assert z.scalar.to_number() == 1, f"scalar is {z.scalar.to_number()}"
# >> AssertionError: scalar is (-1.8369701987210297e-16-1j)
version: pyzx 0.8.0
The text was updated successfully, but these errors were encountered:
Looking into this further, the problem was simply that BaseGraph.adjoint() did not conjugate the phase. Adding the line g.scalar.add_phase(- 2 * g.scalar.phase) in BaseGraph.copy fixed everything.
In the following code snippet, the two tensors differ by a phase of 1j. Running this for different seeds, I find that the phase of
z
is either [1, 1j, -1, -1j].version: pyzx 0.8.0
The text was updated successfully, but these errors were encountered: