Skip to content

Commit

Permalink
Update Gatemap creation (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
glorialeezero authored Nov 22, 2024
2 parents 1109823 + 2397bf7 commit bf8085a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 6 additions & 0 deletions qupsy/bin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
from pathlib import Path
from typing import cast

from qupsy.spec import parse_spec
from qupsy.utils import logger
Expand All @@ -8,12 +9,17 @@
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--dry-run", action="store_true", help="Dry run")
parser.add_argument("-l", "--loglevel", default="WARNING", help="Log level")
parser.add_argument(
"specification", type=Path, metavar="SPEC", help="Specification file"
)

args = parser.parse_args()

loglevel = cast(str, args.loglevel).upper()
logger.setLevel(loglevel)
logger.debug("CLI arguments: %s", args)

logger.debug("Specification file: %s", args.specification)
spec = parse_spec(args.specification)

Expand Down
7 changes: 7 additions & 0 deletions qupsy/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,10 @@ def cost(self) -> int:
@property
def depth(self) -> int:
return self.body.depth


GATE_MAP: dict[str, type[Gate]] = {
g.__name__: g
for g in globals().values()
if isinstance(g, type) and issubclass(g, Gate)
}
10 changes: 1 addition & 9 deletions qupsy/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@
import numpy as np
import numpy.typing as npt

from qupsy.language import CX, CRy, Gate, H, Ry, X
from qupsy.language import GATE_MAP, Gate
from qupsy.utils import logger

GATE_MAP: dict[str, type[Gate]] = {
"H": H,
"X": X,
"Ry": Ry,
"CX": CX,
"CRy": CRy,
}


@dataclass
class Spec:
Expand Down

0 comments on commit bf8085a

Please sign in to comment.