I have written a tonne of tests that compare against A&B's original C++. Until I can distribute the `anders_briegel` package which implements that original code, we now skip those tests if we see an ImportError. TODO: seems a little over-zealous right now ...master
@@ -4,8 +4,12 @@ Mock graphs used for testing | |||||
import numpy as np | import numpy as np | ||||
from abp import GraphState, clifford, qi | from abp import GraphState, clifford, qi | ||||
from anders_briegel import graphsim | |||||
from numpy import random | from numpy import random | ||||
import nose | |||||
try: | |||||
from anders_briegel import graphsim | |||||
except ImportError: | |||||
raise nose.SkipTest("Original C++ is not available, skipping test") | |||||
# We always run with A&B's CZ table when we are testing | # We always run with A&B's CZ table when we are testing | ||||
clifford.use_old_cz() | clifford.use_old_cz() | ||||
@@ -1,5 +1,4 @@ | |||||
from abp import GraphState, CircuitModel, clifford | from abp import GraphState, CircuitModel, clifford | ||||
from anders_briegel import graphsim | |||||
import numpy as np | import numpy as np | ||||
from numpy import random | from numpy import random | ||||
from tqdm import tqdm | from tqdm import tqdm | ||||
@@ -4,8 +4,8 @@ import itertools as it | |||||
from abp import clifford | from abp import clifford | ||||
from abp import build_tables | from abp import build_tables | ||||
from abp import qi | from abp import qi | ||||
import nose | |||||
from nose.tools import raises | from nose.tools import raises | ||||
from anders_briegel import graphsim | |||||
def identify_pauli(m): | def identify_pauli(m): | ||||
@@ -79,6 +79,12 @@ def test_commuters(): | |||||
def test_conjugation(): | def test_conjugation(): | ||||
""" Test that clifford.conugate() agrees with graphsim.LocCliffOp.conjugate """ | """ Test that clifford.conugate() agrees with graphsim.LocCliffOp.conjugate """ | ||||
try: | |||||
from anders_briegel import graphsim | |||||
except ImportError: | |||||
raise nose.SkipTest("Original C++ is not available, skipping test") | |||||
for operation_index, transform_index in it.product(range(4), range(24)): | for operation_index, transform_index in it.product(range(4), range(24)): | ||||
transform = graphsim.LocCliffOp(transform_index) | transform = graphsim.LocCliffOp(transform_index) | ||||
operation = graphsim.LocCliffOp(operation_index) | operation = graphsim.LocCliffOp(operation_index) | ||||
@@ -1,7 +1,6 @@ | |||||
import numpy as np | import numpy as np | ||||
from abp import GraphState | from abp import GraphState | ||||
from abp import qi, clifford | from abp import qi, clifford | ||||
from anders_briegel import graphsim | |||||
from tqdm import tqdm | from tqdm import tqdm | ||||
import random | import random | ||||
import itertools as it | import itertools as it | ||||
@@ -2,6 +2,7 @@ import numpy as np | |||||
from abp import qi, GraphState | from abp import qi, GraphState | ||||
from tqdm import tqdm | from tqdm import tqdm | ||||
import mock | import mock | ||||
import nose | |||||
DEPTH = 1000 | DEPTH = 1000 | ||||
@@ -126,8 +127,7 @@ def test_against_chp(n=5): | |||||
try: | try: | ||||
import chp | import chp | ||||
except ImportError: | except ImportError: | ||||
print "Not testing against CHP -- not installed" | |||||
return | |||||
raise nose.SkipTest("CHP is not installed") | |||||
def get_chp_state(): | def get_chp_state(): | ||||
""" Helper to convert CHP to CircuitModel """ | """ Helper to convert CHP to CircuitModel """ | ||||