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

Fix bug in Spec.__str__ #14

Merged
merged 2 commits into from
Nov 25, 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
11 changes: 7 additions & 4 deletions qupsy/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ def __str__(self) -> str:
testcases_string.append(
f" ( Input: {input_str},\n Output: {output_str}),"
)
return f"""Spec(
gates: [{", ".join(map(lambda g: g.__name__, self.gates))}],
return """Spec(
gates: [{}],
testcases: [
{"\n".join(testcases_string)}
{}
],
)"""
)""".format(
", ".join(map(lambda g: g.__name__, self.gates)),
"\n".join(testcases_string),
)


def make_spec(data: SpecData) -> Spec:
Expand Down
18 changes: 1 addition & 17 deletions qupsy/utils.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
import logging
import os

from rich.console import Console
from rich.logging import RichHandler

console = Console()


_log_level = os.environ.get("LOG_LEVEL")
if _log_level is not None:
_log_level = _log_level.upper()
_log_level = logging.getLevelNamesMapping()[_log_level]


_hander = RichHandler(
console=console,
show_path=_log_level is not None and _log_level == logging.DEBUG,
)

_hander = RichHandler(console=console, show_path=False)
_hander.setFormatter(logging.Formatter(fmt="%(message)s", datefmt="[%X]"))

logger = logging.getLogger("quspy")
logger.addHandler(_hander)
if _log_level is not None:
logger.setLevel(_log_level)