Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test_search.py #22

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/test_search.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from pathlib import Path

from qupsy.language import CX, ForCmd, GateCmd, H, Integer, Pgm, SeqCmd, Var
from qupsy.search import search
from qupsy.spec import make_spec, SpecData

DATA_DIR = Path(__file__).parent / "data"


def test_search_ghz_last_step():
init_pgm = Pgm(
Expand Down
18 changes: 16 additions & 2 deletions tests/test_spec.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from qupsy.language import CX, H
from qupsy.spec import Spec, SpecData, make_spec, parse_spec
from qupsy.spec import Spec, SpecData, make_spec


def test_parse_spec_from_raw_data():
Expand Down Expand Up @@ -39,7 +39,21 @@ def test_parse_spec_from_raw_data():


def test_parse_spec_from_json_data():
spec = parse_spec("tests/data/ghz.json")
raw_spec: SpecData = {
"gates": ["H", "CX"],
"testcases": {
"1": {
"input": None,
"output": "0.70710677,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.70710677",
},
"2": {
"input": None,
"output": "0.70710677, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.70710677",
},
"3": {"input": None, "output": "0.70710677,0,0,0,0,0,0,0.70710677"},
},
}
spec = make_spec(raw_spec)
assert spec.gates == [H, CX]
assert len(spec.testcases) == 3
assert isinstance(spec, Spec)
Loading