Skip to content

[Bug] Open graphs without measurements #2

@matulni

Description

@matulni

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

  1. When creating an OpenGraph object, check that all nodes $i \in O^c$ have measurements attached.
  2. Assign default $(\lambda = XY, \alpha = 0)$ measurements when creating an OpenGraph object.
  3. 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 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions