eclipse-qrisp / Qrisp

Qrisp - a framework for high-level programming of Quantum computers
https://www.qrisp.eu/
Eclipse Public License 2.0
83 stars 23 forks source link

Bug report: recursive_qs_search #42

Open renezander90 opened 5 months ago

renezander90 commented 5 months ago

A error occurs when recursive_qs_search is applied to a network.Graph.

from qrisp import *
import networkx as nx

def test(G, qv):
    h(qv)

qv = QuantumVariable(1)
G = nx.Graph()
G.add_edges_from([(0, 1), (0, 2)])

with conjugate(test)(G, qv):
    h(qv)

Here, the conjugation environment applies recursive_qs_search to the arguments G, qv. If G is a networkx.Graph this yields an error.

A workaround would be hiding the graph G:

from qrisp import *
import networkx as nx

def test_workaround(G, qv):
    def test(qv):
        h(qv)
    return test     

qv = QuantumVariable(1)
G = nx.Graph()
G.add_edges_from([(0, 1), (0, 2)])

test = test_workaround(G, qv)

with conjugate(test)(qv):
    h(qv)