Skip to content

Commit

Permalink
Merge branch 'main' into latexfix
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored May 13, 2024
2 parents 373b34e + 23bb57e commit 4402940
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion nix-support/pytket.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ in {
inherit version;
propagatedBuildInputs = with super.python3.pkgs; [
self.binders
super.lark-parser
super.lark
super.types-pkg_resources
super.qwasm
graphviz
Expand Down
12 changes: 7 additions & 5 deletions nix-support/third-party-python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ self: super: {
sha256 = "sha256:g/QA5CpAR3exRDgVQMnXGIH8bEGtwGFBjjSblbdXRkU=";
};
};
lark-parser = super.python3.pkgs.buildPythonPackage {
pname = "lark-parser";
version = "0.12.0";
lark = super.python3.pkgs.buildPythonPackage {
pname = "lark";
version = "1.1.9";
format = "pyproject";
src = super.fetchFromGitHub {
owner = "lark-parser";
repo = "lark";
rev = "refs/tags/0.12.0";
hash = "sha256-zcMGCn3ixD3dJg3GlC/ijs+U1JN1BodHLTXZc/5UR7Y=";
rev = "refs/tags/1.1.9";
hash = "sha256:pWLKjELy10VNumpBHjBYCO2TltKsZx1GhQcGMHsYJNk=";
};
nativeBuildInputs = with super.python3Packages; [ setuptools ];
doCheck = false;
};
types-pkg_resources = let
Expand Down
1 change: 1 addition & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Features:

* Update to pytket-circuit-renderer 0.8.
* Add two new status values for circuits on backends: "CANCELLING" and "RETRYING".
* Use `lark` package instead of deprecated `lark-parser`.

Fixes:

Expand Down
4 changes: 2 additions & 2 deletions pytket/pytket/qasm/qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def assign(self, tree: List) -> Iterable[CommandDict]:
else:
raise QASMParseError(f"Unexpected expression in assignment {exp}", line)

def extern(self, tree: List[Any]) -> Type[Discard]:
def extern(self, tree: List[Any]) -> Any:
# TODO parse extern defs
return Discard

Expand Down Expand Up @@ -899,7 +899,7 @@ def gdef(self, tree: List) -> None:

opaq = gdef

def oqasm(self, tree: List) -> Type[Discard]:
def oqasm(self, tree: List) -> Any:
return Discard

def incl(self, tree: List[Token]) -> None:
Expand Down
19 changes: 11 additions & 8 deletions pytket/pytket/quipper/quipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class Subroutine_Control(Enum):
)
Start = NamedTuple("Start", [("circuit", Program), ("subroutines", List[Subroutine])])


# Transformer
class QuipperTransformer(Transformer):
def int(self, t: List) -> int:
Expand Down Expand Up @@ -284,18 +285,20 @@ def cdiscard(self, t: List) -> CDiscard:
return CDiscard(wire=t[0])

def subroutine_call(self, t: List) -> SubroutineCall:
for i, ti in enumerate(t):
print(f"t[{i}] = {ti}")
repetitions = 1
if isinstance(t[0], int):
if t[0] is not None:
assert isinstance(t[0], int)
repetitions = t[0]
t.pop(0)
return SubroutineCall(
repetitions=repetitions,
name=t[0],
shape=t[1],
inverted=len(t[2].children) > 0,
inputs=t[3],
outputs=t[4],
control=t[5],
name=t[1],
shape=t[2],
inverted=len(t[3].children) > 0,
inputs=t[4],
outputs=t[5],
control=t[6],
)

def comment(self, t: List) -> Comment:
Expand Down
2 changes: 1 addition & 1 deletion pytket/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def finalize_options(self):
install_requires=[
"sympy ~=1.6",
"numpy >=1.21.4, <2.0",
"lark-parser ~=0.7",
"lark ~=1.1",
"scipy ~=1.13",
"networkx >= 2.8.8",
"graphviz ~= 0.14",
Expand Down

0 comments on commit 4402940

Please sign in to comment.