def load(psi): state = StabilizerState(psi["n"], psi["k"]) state.G = np.array(psi["G"]) state.Gbar = np.array(psi["Gbar"]) state.h = np.array(psi["h"]) if "D" in psi: state.D = np.array(psi["D"])[:state.k] state.J = np.array(psi["J"])[:state.k, :state.k]*4 state.Q = psi["Q"] return state
def load(psi): state = StabilizerState(psi["n"], psi["k"]) state.G = np.array(psi["G"]) state.Gbar = np.array(psi["Gbar"]) state.h = np.array(psi["h"]) if "D" in psi: state.D = np.array(psi["D"])[:state.k] state.J = np.array(psi["J"])[:state.k, :state.k] * 4 state.Q = psi["Q"] return state
indexcut = 0 failed = 0 index = 0 starttime = datetime.now() for test in tests: index += 1 if index < indexcut: continue # don't actually depend on n, but need for initialization k = len(test["D"]["D"]) # k = 4 state = StabilizerState(k, k) # state.D = np.array(test["D"]["D"])[:4] state.D = np.array(test["D"]["D"]) # state.J = np.array(test["J"]["J"])[:4, :4]*4 state.J = np.array(test["J"]["J"])*4 state.Q = test["Q"]["Q"] (eps, p, m) = state.exponentialSum(exact=True) if eps != test["eps_out"]\ or m != test["m_out"] % 8\ or p != test["p_out"]: if failed == 0: print("ExponentialSum errors:") print("ExponentialSum %d (k=%d) failed: (%d,%d,%d) should be (%d,%d,%d)" % (index, state.k, eps, p, m, test["eps_out"], test["p_out"], test["m_out"])) failed += 1 # break if len(tests) == 0: print("[\033[93mSkipped\033[0m] ExponentialSum") else: if failed == 0: print("[\033[92mPassed\033[0m] ExponentialSum: %d tests in " % len(tests) + str(datetime.now() - starttime))
indexcut = 0 failed = 0 index = 0 starttime = datetime.now() for test in tests: index += 1 if index < indexcut: continue # don't actually depend on n, but need for initialization k = len(test["D"]["D"]) # k = 4 state = StabilizerState(k, k) # state.D = np.array(test["D"]["D"])[:4] state.D = np.array(test["D"]["D"]) # state.J = np.array(test["J"]["J"])[:4, :4]*4 state.J = np.array(test["J"]["J"]) * 4 state.Q = test["Q"]["Q"] (eps, p, m) = state.exponentialSum(exact=True) if eps != test["eps_out"]\ or m != test["m_out"] % 8\ or p != test["p_out"]: if failed == 0: print("ExponentialSum errors:") print( "ExponentialSum %d (k=%d) failed: (%d,%d,%d) should be (%d,%d,%d)" % (index, state.k, eps, p, m, test["eps_out"], test["p_out"], test["m_out"])) failed += 1 # break if len(tests) == 0: print("[\033[93mSkipped\033[0m] ExponentialSum")