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 mypy and pytket #363

Merged
merged 2 commits into from
Jul 9, 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
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
~~~~~~~~~

0.55.0 (unreleased)
-------------------

* Updated pytket version requirement to 1.30.0rc0.

0.54.1 (June 2024)
------------------

Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ ignore_errors = True
[mypy-lark.*]
ignore_missing_imports = True
ignore_errors = True

[mypy-sympy.*]
ignore_missing_imports = True
12 changes: 6 additions & 6 deletions pytket/extensions/qiskit/qiskit_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ def param_to_tk(p: Union[float, ParameterExpression]) -> sympy.Expr:
if isinstance(p, ParameterExpression):
symexpr = p._symbol_expr
try:
return symexpr._sympy_() / sympy.pi # type: ignore
return symexpr._sympy_() / sympy.pi
except AttributeError:
return symexpr / sympy.pi # type: ignore
return symexpr / sympy.pi
else:
return p / sympy.pi # type: ignore
return p / sympy.pi


def param_to_qiskit(
Expand All @@ -584,7 +584,7 @@ def param_to_qiskit(
def _get_params(
op: Op, symb_map: Dict[Parameter, sympy.Symbol]
) -> List[Union[float, ParameterExpression]]:
return [param_to_qiskit(p, symb_map) for p in op.params] # type: ignore
return [param_to_qiskit(p, symb_map) for p in op.params]


def append_tk_command_to_qiskit(
Expand Down Expand Up @@ -706,7 +706,7 @@ def append_tk_command_to_qiskit(
if optype == OpType.CnRy:
# might as well do a bit more checking
assert len(op.params) == 1
alpha = param_to_qiskit(op.params[0], symb_map) # type: ignore
alpha = param_to_qiskit(op.params[0], symb_map)
assert len(qargs) >= 2
if len(qargs) == 2:
# presumably more efficient; single control only
Expand Down Expand Up @@ -834,7 +834,7 @@ def tk_to_qiskit(
append_tk_command_to_qiskit(
command.op, command.args, qcirc, qregmap, cregmap, symb_map, range_preds
)
qcirc.global_phase += param_to_qiskit(tkc.phase, symb_map) # type: ignore
qcirc.global_phase += param_to_qiskit(tkc.phase, symb_map)

# if UUID stored in name, set parameter uuids accordingly (see qiskit_to_tk)
updates = dict()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
packages=find_namespace_packages(include=["pytket.*"]),
include_package_data=True,
install_requires=[
"pytket >= 1.29",
"pytket >= 1.30.0rc0",
"qiskit >= 1.1",
"qiskit-algorithms >= 0.3.0",
"qiskit-ibm-runtime >= 0.24.1",
Expand Down
10 changes: 5 additions & 5 deletions tests/qiskit_convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ def test_convert() -> None:


def test_symbolic() -> None:
pi2 = Symbol("pi2") # type: ignore
pi3 = Symbol("pi3") # type: ignore
pi0 = Symbol("pi0") # type: ignore
pi2 = Symbol("pi2")
pi3 = Symbol("pi3")
pi0 = Symbol("pi0")
tkc = Circuit(3, 3, name="test").Ry(pi2, 1).Rx(pi3, 1).CX(1, 0)
tkc.add_phase(Symbol("pi0") * 2) # type: ignore
tkc.add_phase(Symbol("pi0") * 2)
RebaseTket().apply(tkc)

qc = tk_to_qiskit(tkc)
Expand Down Expand Up @@ -502,7 +502,7 @@ def test_gate_str_2_optype() -> None:


def test_customgate() -> None:
a = Symbol("a") # type: ignore
a = Symbol("a")
def_circ = Circuit(2)
def_circ.CZ(0, 1)
def_circ.Rx(a, 1)
Expand Down