From 9377249675d110795dcb1cf628f4b28a293b51f2 Mon Sep 17 00:00:00 2001 From: Sam Morley-Short Date: Wed, 2 Nov 2016 23:47:06 +0000 Subject: [PATCH 1/2] measure_sequences added, not yet working --- abp/graphstate.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) mode change 100644 => 100755 abp/graphstate.py diff --git a/abp/graphstate.py b/abp/graphstate.py old mode 100644 new mode 100755 index f443e0d..2bea4ab --- a/abp/graphstate.py +++ b/abp/graphstate.py @@ -292,6 +292,27 @@ class GraphState(object): """ return self.measure(node, "pz", force, detail) + def measure_sequence(self, measurements, forces=None, detail=False): + """ Measures a sequence of Paulis + + :param measurements: The sequence of measurements to be made, in the form [(node, basis), ...] + :type force: list of tuples + :param force: Measurements in quantum mechanics are probabilistic. If you want to force a particular outcome, use the ``force``. List outcome force values in same order as measurements + :type force: list + :param detail: Provide detailed information + :type detail: boolean + + """ + forces = forces if forces != None else [random.choice([0, 1]) for i in range(len(measurements))] + measurements = zip(measurements, forces) + print measurements + results = [] + for (node, basis), force in measurements: + result = self.measure(node, basis, force, detail) + print result + results += [result] + return results + def _toggle_edges(self, a, b): """ Toggle edges between vertex sets a and b """ # TODO: i'm pretty sure this is just a single-line it.combinations or From 10860e20660d864b49d4e00473919f1879eacef3 Mon Sep 17 00:00:00 2001 From: Sam Morley-Short Date: Thu, 3 Nov 2016 08:59:21 +0000 Subject: [PATCH 2/2] measure_sequence now working, was not in develop mode :baby: --- abp/graphstate.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/abp/graphstate.py b/abp/graphstate.py index 2bea4ab..b80172d 100755 --- a/abp/graphstate.py +++ b/abp/graphstate.py @@ -305,11 +305,9 @@ class GraphState(object): """ forces = forces if forces != None else [random.choice([0, 1]) for i in range(len(measurements))] measurements = zip(measurements, forces) - print measurements results = [] for (node, basis), force in measurements: result = self.measure(node, basis, force, detail) - print result results += [result] return results