Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
pull-requests: write # allows coverage bot to comment
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
Comment thread
bramathon marked this conversation as resolved.
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions docs/source/exercises.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ We can verify this works by computing the *inverse* FFT on the output with NumPy

.. testoutput:: qft

[ 0.00000000e+00+0.00000000e+00j 1.00000000e+00+5.45603965e-17j
[ 0.00000000e+00+0.00000000e+00j 1.00000000e+00+4.30636606e-17j
0.00000000e+00+0.00000000e+00j 0.00000000e+00-1.53080850e-17j
0.00000000e+00+0.00000000e+00j -7.85046229e-17-2.39442265e-17j
0.00000000e+00+0.00000000e+00j -7.85046229e-17-1.24474906e-17j
0.00000000e+00+0.00000000e+00j 0.00000000e+00-1.53080850e-17j]
Comment thread
jselig-rigetti marked this conversation as resolved.

After ignoring the terms that are on the order of ``1e-17``, we get ``[0, 1, 0, 0, 0, 0, 0, 0]``, which was our input!
Expand Down
103 changes: 56 additions & 47 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ license = "Apache-2.0"
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
]
keywords = ["quantum", "quil", "programming", "hybrid"]
packages = [{ include = "pyquil" }]
exclude = ["pyquil/conftest.py"]

[tool.poetry.dependencies]
python = "^3.9,<4.0"
numpy = "^1.25"
python = "^3.9,<3.13"
numpy = ">=1.26"
Comment thread
jselig-rigetti marked this conversation as resolved.
Outdated
scipy = "^1.11"
rpcq = "^3.11.0"
networkx = ">=2.5"
Expand Down Expand Up @@ -63,6 +65,7 @@ pytest-benchmark = "4.0.0"
respx = "^0.21.1"
syrupy = "^4.6.1"
jinja2 = {version = ">=3.1.6", optional = true} # see: https://osv.dev/vulnerability/GHSA-gmj6-6f8f-6699 and https://osv.dev/vulnerability/GHSA-q2x7-8rv6-6q7h and https://osv.dev/GHSA-cpwx-vrp4-4pq7
h11 = {version = ">=0.16.0", optional = true} # see: https://osv.dev/vulnerability/GHSA-vqfr-h8mv-ghfj


[tool.ruff]
Expand Down
2 changes: 1 addition & 1 deletion pyquil/noise_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _transform_rpcq_qubit_gate_info_to_qvm_noise_supported_gate(qubit_id: int, g
return None

parameters = [Parameter(param) if isinstance(param, str) else param for param in gate.parameters]
return Gate(gate.operator, parameters, [unpack_qubit(qubit_id)]) # type: ignore
return Gate(gate.operator, parameters, [unpack_qubit(qubit_id)])

if gate.operator == Supported1QGate.RZ:
return Gate(Supported1QGate.RZ, [Parameter("theta")], [unpack_qubit(qubit_id)])
Expand Down
4 changes: 4 additions & 0 deletions pyquil/quil.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
_convert_to_calibration_match,
)

if np.lib.NumpyVersion(np.__version__) >= "2.0.0b1":
# prevents floats from being printed as `np.float(1.234)`
np.set_printoptions(legacy="1.21")

Comment thread
jselig-rigetti marked this conversation as resolved.
Outdated
InstructionDesignator = Union[
AbstractInstruction,
quil_rs.Instruction,
Expand Down
11 changes: 9 additions & 2 deletions pyquil/quilatom.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
from deprecated.sphinx import deprecated
from typing_extensions import Self

if np.lib.NumpyVersion(np.__version__) >= "2.0.0b1":
# prevents floats from being printed as `np.float(1.234)`
np.set_printoptions(legacy="1.21")


class QuilAtom:
"""Abstract class for atomic elements of Quil."""
Expand Down Expand Up @@ -405,7 +409,7 @@ def format_parameter(element: ParameterDesignator) -> str:
"""
if isinstance(element, (int, np.integer)):
return repr(element)
elif isinstance(element, float):
elif isinstance(element, (float, np.floating)):
return _check_for_pi(element)
elif isinstance(element, complex):
out = ""
Expand Down Expand Up @@ -914,7 +918,7 @@ def _contained_parameters(expression: ExpressionDesignator) -> set[Parameter]:
return set()


def _check_for_pi(element: float) -> str:
def _check_for_pi(element: Union[float, np.floating]) -> str:
"""Return the float as a string, expressing the float as a multiple of pi if possible.

More specifically, check to see if there exists a rational number r = p/q in reduced form for which the difference
Expand All @@ -923,6 +927,9 @@ def _check_for_pi(element: float) -> str:
:param element: the number to check
:return element: pretty print string if true, else standard representation.
"""
if isinstance(element, np.floating):
element = float(element)

frac = Fraction(element / np.pi).limit_denominator(8)
num, den = frac.numerator, frac.denominator
sign = "-" if num < 0 else ""
Expand Down
4 changes: 4 additions & 0 deletions pyquil/quilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
import quil.expression as quil_rs_expr
import quil.instructions as quil_rs

if np.lib.NumpyVersion(np.__version__) >= "2.0.0b1":
# prevents floats from being printed as `np.float(1.234)`
np.set_printoptions(legacy="1.21")


class _InstructionMeta(abc.ABCMeta):
"""A metaclass that allows us to group all instruction types from quil-rs and pyQuil as an `AbstractInstruction`.
Expand Down