Skip to content

Commit

Permalink
Update about() and document latest package support
Browse files Browse the repository at this point in the history
Fixes #1201
  • Loading branch information
crazy4pi314 committed Apr 12, 2022
1 parent b887888 commit 430b542
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions mitiq/_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,34 @@

"""Information about Mitiq and dependencies."""
import platform
from pkg_resources import parse_requirements

from cirq import __version__ as cirq_version
from numpy import __version__ as numpy_version
from scipy import __version__ as scipy_version

import mitiq

OPTIONAL_REQUIREMENTS = [
"pyquil",
"qiskit",
"amazon-braket-sdk",
"pennylane",
"pennylane-qiskit",
]


def latest_supported():
"""Returns the versions of Mitiq's optional packages that are supported by
the current version of Mitiq. Requires that the dependency has a pinned
version in the dev_requirements.txt file.
"""
return {
req.project_name: req.specs[0][1]
for req in parse_requirements(open("dev_requirements.txt"))
if req.project_name in OPTIONAL_REQUIREMENTS
}


def about() -> None:
"""Displays information about Mitiq, core/optional packages, and Python
Expand All @@ -41,6 +62,16 @@ def about() -> None:
from braket._sdk import __version__ as braket_version
except ImportError:
braket_version = "Not installed"
try:
from pennylane import __version__ as pennylane_version
except ImportError:
pennylane_version = "Not installed"
try:
from pennylane_qiskit import __version__ as pennylane_qiskit_version
except ImportError:
pennylane_qiskit_version = "Not installed"

optional_reqs = latest_supported()

about_str = f"""
Mitiq: A Python toolkit for implementing error mitigation on quantum computers
Expand All @@ -57,9 +88,16 @@ def about() -> None:
Optional Dependencies
---------------------
PyQuil Version:\t{pyquil_version}
Qiskit Version:\t{qiskit_version}
Braket Version:\t{braket_version}
PyQuil Version: {pyquil_version}
Latest Supported: {optional_reqs["pyquil"]}
Qiskit Version: {qiskit_version}
Latest Supported: {optional_reqs["qiskit"]}
Braket Version: {braket_version}
Latest Supported: {optional_reqs["amazon-braket-sdk"]}
PennyLane Version: {pennylane_version}
Latest Supported: {optional_reqs["pennylane"]}
PennyLane-Qiskit Version: {pennylane_qiskit_version}
Latest Supported: {optional_reqs["pennylane-qiskit"]}
Python Version:\t{platform.python_version()}
Platform Info:\t{platform.system()} ({platform.machine()})"""
Expand Down

0 comments on commit 430b542

Please sign in to comment.