Skip to content

Commit

Permalink
Update test_search.py (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
glorialeezero authored Dec 6, 2024
2 parents a78b3b6 + 8985486 commit 0b693c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
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)

0 comments on commit 0b693c5

Please sign in to comment.