Description
Current interface allows to create OpenGraph objects without specifying any measurements, i.e., passing an empty dict to the measurements argument.
In this scenario, the method OpenGraph.to_pattern() calls graphix.generator.generate_from_graph(graph, angles, inputs, outputs, meas_planes) with angles = dict() which results in a KeyError.
Minimal example
import networkx as nx
from graphix.fundamentals import Plane
from graphix.measurements import Measurement
from graphix.opengraph import OpenGraph
# Problematic Open Graph
def test_og_without_meas():
graph = nx.Graph([(0, 1), (1, 2)])
inputs = [0]
outputs = [2]
meas = {}
og = OpenGraph(inside=graph, inputs=inputs, outputs=outputs, measurements=meas)
og.to_pattern() #-> yields an error
# OK Open Graph
def test_og_with_meas():
graph = nx.Graph([(0, 1), (1, 2)])
inputs = [0]
outputs = [2]
meas = {i: Measurement(0, Plane.XY) for i in (set(graph.nodes())- set(outputs))}
og = OpenGraph(inside=graph, inputs=inputs, outputs=outputs, measurements=meas)
og.to_pattern()
Possible solutions
- When creating an
OpenGraph object, check that all nodes $i \in O^c$ have measurements attached.
- Assign default $(\lambda = XY, \alpha = 0)$ measurements when creating an
OpenGraph object.
- Assign default $(\lambda = XY, \alpha = 0)$ measurements when generating a
Pattern from an OpenGraph object.
Currently, option 3 is partially implemented by assigning default measurement planes ($XY$) at the level of graphix.generator.generate_from_graph(graph, angles, inputs, outputs, meas_planes). (See #3 )
Description
Current interface allows to create
OpenGraphobjects without specifying any measurements, i.e., passing an emptydictto themeasurementsargument.In this scenario, the method
OpenGraph.to_pattern()callsgraphix.generator.generate_from_graph(graph, angles, inputs, outputs, meas_planes)withangles = dict()which results in aKeyError.Minimal example
Possible solutions
OpenGraphobject, check that all nodesOpenGraphobject.Patternfrom anOpenGraphobject.Currently, option 3 is partially implemented by assigning default measurement planes ($XY$ ) at the level of
graphix.generator.generate_from_graph(graph, angles, inputs, outputs, meas_planes). (See #3 )