Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
glorialeezero committed Nov 21, 2024
1 parent 69a3db3 commit bce4cce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion qupsy/bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--dry-run", action="store_true", help="Dry run")
parser.add_argument("specification", type=Path, metavar="SPEC", help="Specification file")
parser.add_argument(
"specification", type=Path, metavar="SPEC", help="Specification file"
)

args = parser.parse_args()

Expand Down
14 changes: 11 additions & 3 deletions qupsy/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ def __str__(self) -> str:
input_str = str(input).splitlines()
input_str = input_str[0] + " ...]" if len(input_str) > 1 else input_str[0]
output_str = str(output).splitlines()
output_str = output_str[0] + " ...]" if len(output_str) > 1 else output_str[0]
output_str = (
output_str[0] + " ...]" if len(output_str) > 1 else output_str[0]
)

testcases_string.append(f" ( Input: {input_str},\n Output: {output_str}),")
testcases_string.append(
f" ( Input: {input_str},\n Output: {output_str}),"
)
return f"""Spec(
gates: [{", ".join(map(lambda g: g.__name__, self.gates))}],
testcases: [
Expand All @@ -50,7 +54,11 @@ def parse_spec(spec: Path | str) -> Spec:
testcases: list[tuple[npt.ArrayLike, npt.ArrayLike]] = []
for tc in data["testcases"].values():
output = np.fromstring(tc["output"], dtype="complex", sep=",")
input = tc["input"] if "input" in tc else (np.concat([[1], np.zeros_like(output[1:])]))
input = (
tc["input"]
if "input" in tc
else (np.concat([[1], np.zeros_like(output[1:])]))
)
testcases.append((input, output))

logger.debug("Parsed output: %s", output)
Expand Down

0 comments on commit bce4cce

Please sign in to comment.