Skip to content

Commit

Permalink
Fix lint, update tests with doc building
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikandreasseitz committed Jan 23, 2024
1 parent db7a597 commit f7b2d1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions horqrux/abstract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Callable, Iterable, Tuple
from typing import Any, Iterable, Tuple

import numpy as np
from jax import Array
Expand Down Expand Up @@ -48,7 +48,7 @@ def __post_init__(self) -> None:
def __iter__(self) -> Iterable:
return iter((self.generator_name, self.target, self.control))

def tree_flatten(self) -> Tuple[Tuple, Tuple[str, QubitSupport, QubitSupport]]:
def tree_flatten(self) -> Tuple[Tuple, Tuple[str, TargetQubits, ControlQubits]]:
children = ()
aux_data = (self.generator_name, self.target, self.control)
return (children, aux_data)
Expand Down Expand Up @@ -86,13 +86,14 @@ def __post_init__(self) -> None:
super().__post_init__()

def parse_dict(values: dict[str, float] = {}) -> float:
return values[self.param]
return values[self.param] # type: ignore[index]

self.parse_values: Callable[[dict[str, float]], float] = (
parse_dict if isinstance(self.param, str) else lambda x: self.param
)
def parse_val(values: dict[str, float] = {}) -> float:
return self.param # type: ignore[return-value]

self.parse_values = parse_dict if isinstance(self.param, str) else parse_val

def tree_flatten(self) -> Tuple[Tuple, Tuple[str, TargetQubits, ControlQubits, str | float]]:
def tree_flatten(self) -> Tuple[Tuple, Tuple[str, Tuple, Tuple, str | float]]: # type: ignore[override]
children = ()
aux_data = (
self.name,
Expand Down
6 changes: 3 additions & 3 deletions horqrux/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def RX(param: float | str, target: TargetQubits, control: ControlQubits = (None,
Returns:
Parametric: A Parametric gate object.
"""
return Parametric("X", target, control, param=param)
return Parametric("X", target, control, param)


def RY(param: float | str, target: TargetQubits, control: ControlQubits = (None,)) -> Parametric:
Expand All @@ -32,7 +32,7 @@ def RY(param: float | str, target: TargetQubits, control: ControlQubits = (None,
Returns:
Parametric: A Parametric gate object.
"""
return Parametric("Y", target, control, param=param)
return Parametric("Y", target, control, param)


def RZ(param: float | str, target: TargetQubits, control: ControlQubits = (None,)) -> Parametric:
Expand All @@ -46,7 +46,7 @@ def RZ(param: float | str, target: TargetQubits, control: ControlQubits = (None,
Returns:
Parametric: A Parametric gate object.
"""
return Parametric("Z", target, control, param=param)
return Parametric("Z", target, control, param)


class _PHASE(Parametric):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ features = [
]

[tool.hatch.envs.tests.scripts]
test = "pytest -n auto {args}"
test = "pytest -n auto {args} && hatch -e docs run docs:build"

[tool.hatch.envs.docs]
dependencies = [
Expand Down

0 comments on commit f7b2d1c

Please sign in to comment.