Skip to content

Commit

Permalink
fix: correctly passing local variables when converting qref_v1 object…
Browse files Browse the repository at this point in the history
… to bartiq routine

This PR modifies the _routine_v1_to_bartiq_routine function to ensure that local variables are correctly passed and included when converting qref to bartiq routine.
  • Loading branch information
sitong1011 authored Jul 11, 2024
1 parent c0ee3ea commit 295ce32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bartiq/integrations/qref.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def _routine_v1_to_bartiq_routine(routine_v1) -> Routine:
type=routine_v1.type,
ports={port.name: port.model_dump() for port in routine_v1.ports},
resources={resource.name: resource.model_dump() for resource in routine_v1.resources},
local_variables=routine_v1.local_variables,
connections=[connection.model_dump() for connection in routine_v1.connections],
input_params=routine_v1.input_params,
linked_params={
Expand Down
8 changes: 8 additions & 0 deletions tests/integrations/test_qref_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def example_routine():
"name": "foo",
"type": None,
"input_params": ["M"],
"local_variables": [
"R=ceiling(log_2(M))",
],
"resources": {"T_gates": {"name": "T_gates", "type": "additive", "value": "R ** 2"}},
"ports": {
"in_0": {"name": "in_0", "size": "M", "direction": "input"},
"out_0": {"name": "out_0", "size": 3, "direction": "output"},
Expand Down Expand Up @@ -93,6 +97,10 @@ def example_serialized_qref_v1_object():
{"name": "out_0", "direction": "output", "size": 3},
],
"input_params": ["M"],
"local_variables": [
"R=ceiling(log_2(M))",
],
"resources": [{"name": "T_gates", "type": "additive", "value": "R ** 2"}],
},
],
"type": None,
Expand Down

0 comments on commit 295ce32

Please sign in to comment.