def test_ordering(self): """ See that we can simulate an MZI""" postdata = { "circuit": TWO_COUPLERS, "format": "table", "mode": "probability" } request = {"body": json.dumps(postdata)} output = json.loads(views.simulate(request).content) assert all(output[i][1] >= output[i + 1][1] for i in range(len(output) - 1))
def test_ordering(self): """ See that we can simulate an MZI""" postdata = {"circuit" : TWO_COUPLERS, "format":"table", "mode":"probability"} request = {"body": json.dumps(postdata)} output = json.loads(views.simulate(request).content) assert all(output[i][1]>=output[i+1][1] for i in range(len(output)-1))
def test_mzi(self): """ See that we can simulate an MZI""" postdata = {"circuit" : MZI, "format":"dict", "mode":"amplitude"} request = {"body": json.dumps(postdata)} output = json.loads(views.simulate(request).content) self.assertAlmostEqual(output["(1,)"]["imag"], 1)
def test_no_nonzero(self): """ What happens when have an empty circuit ? """ postdata = {"circuit" : []} request = {"body": json.dumps(postdata)} output = views.simulate(request) self.assertEqual(output.status_code, 400)
def test_mzi(self): """ See that we can simulate an MZI""" postdata = {"circuit": MZI, "format": "dict", "mode": "amplitude"} request = {"body": json.dumps(postdata)} output = json.loads(views.simulate(request).content) self.assertAlmostEqual(output["(1,)"]["imag"], 1)
def test_no_nonzero(self): """ What happens when have an empty circuit ? """ postdata = {"circuit": []} request = {"body": json.dumps(postdata)} output = views.simulate(request) self.assertEqual(output.status_code, 400)