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

make warnings into errors #6641

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bfee1c2
make warnings into errors
timmysilv Nov 26, 2024
24cdee6
Merge branch 'master' into warnings-as-errors
timmysilv Nov 26, 2024
64778bf
no torch filter
timmysilv Nov 26, 2024
d51baba
use the pytest warnings oopsie
timmysilv Nov 27, 2024
e339b0d
better filters
timmysilv Nov 27, 2024
1049b18
Merge branch 'master' into warnings-as-errors
timmysilv Nov 27, 2024
9fcf6b0
fix readout warning filter
timmysilv Nov 27, 2024
aa5953f
catch readout errors manually
timmysilv Nov 27, 2024
7ea5cb7
fix new failures
timmysilv Nov 27, 2024
d173213
remove relics of old actions
timmysilv Nov 27, 2024
ff8223f
Merge branch 'master' into warnings-as-errors
timmysilv Nov 27, 2024
2f79aba
restore workflow from master
timmysilv Nov 27, 2024
d23e055
only use -W if warnings_as_errors
timmysilv Nov 27, 2024
0a88595
chop down the list
timmysilv Nov 29, 2024
75e657f
Merge branch 'master' into warnings-as-errors
timmysilv Nov 29, 2024
3153249
more fixes
timmysilv Dec 2, 2024
7d97d11
Merge branch 'master' into warnings-as-errors
timmysilv Dec 2, 2024
e7dfc6f
more fixes
timmysilv Dec 2, 2024
f89d29c
undo accidentally committed comment
timmysilv Dec 2, 2024
caf2c5a
actually call construct_tape; catch qiskit deprecation warning
timmysilv Dec 2, 2024
d0300b9
do not use tape property
timmysilv Dec 2, 2024
e72ab61
Merge branch 'master' into warnings-as-errors
timmysilv Dec 9, 2024
4a526ae
use pennylane numpy to avoid warning
timmysilv Dec 9, 2024
92fbe16
use older qiskit warning
timmysilv Dec 9, 2024
e206560
Merge branch 'master' into warnings-as-errors
timmysilv Dec 10, 2024
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
60 changes: 30 additions & 30 deletions .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ on:
required: false
type: boolean
default: false
python_warning_level:
description: Sets the default Python warning level as defined by https://docs.python.org/3/using/cmdline.html#envvar-PYTHONWARNINGS
warnings_as_errors:
description: Set the Python warning level to `error`
required: false
type: string
default: 'default'
type: boolean
default: false
env:
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true
Expand All @@ -98,7 +98,7 @@ jobs:
- name: Set fail-fast for WAE
id: mat_fail_fast
run: |
echo "fail_fast=${{ contains(inputs.python_warning_level, 'default') && 'default' || 'error' }}" >> $GITHUB_OUTPUT
echo "fail_fast=${{ inputs.warnings_as_errors == 'false' && 'yes' || 'no' }}" >> $GITHUB_OUTPUT

outputs:
fail_fast: ${{ steps.mat_fail_fast.outputs.fail_fast }}
Expand All @@ -123,7 +123,7 @@ jobs:
"default": ["3.10"]
}
EOF
elif [ "${{ inputs.python_warning_level }}" == "error" ];
elif [ "${{ inputs.warnings_as_errors }}" == "true" ];
then
cat >python_versions.json <<-EOF
{
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).torch-tests
Expand All @@ -241,7 +241,7 @@ jobs:
${{ needs.default-dependency-versions.outputs.pytorch-version }}
${{ inputs.additional_python_packages }}
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: torch and not qcut and not finite-diff and not param-shift
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'torch.txt' || '' }}
Expand All @@ -254,7 +254,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).autograd-tests
Expand All @@ -277,7 +277,7 @@ jobs:
additional_pip_packages: ${{ inputs.additional_python_packages }}
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
pytest_markers: autograd and not qcut and not finite-diff and not param-shift


Expand All @@ -288,7 +288,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).tf-tests
Expand All @@ -315,7 +315,7 @@ jobs:
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: tf and not qcut and not finite-diff and not param-shift
pytest_additional_args: --splits 3 --group ${{ matrix.group }} -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: --splits 3 --group ${{ matrix.group }} ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
pytest_durations_file_path: '.github/durations/tf_tests_durations.json'
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'tf.txt' || '' }}

Expand All @@ -326,7 +326,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).jax-tests
Expand All @@ -353,7 +353,7 @@ jobs:
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: jax and not qcut and not finite-diff and not param-shift
pytest_additional_args: --dist=loadscope --splits 4 --group ${{ matrix.group }} -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: --dist=loadscope --splits 4 --group ${{ matrix.group }} ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
pytest_durations_file_path: '.github/durations/jax_tests_durations.json'
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'jax.txt' || '' }}

Expand All @@ -365,7 +365,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).core-tests
Expand All @@ -390,7 +390,7 @@ jobs:
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: core and not qcut and not finite-diff and not param-shift
pytest_additional_args: --splits 6 --group ${{ matrix.group }} -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: --splits 6 --group ${{ matrix.group }} ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
pytest_durations_file_path: '.github/durations/core_tests_durations.json'
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'core.txt' || '' }}

Expand All @@ -402,7 +402,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).all-interfaces-tests
Expand Down Expand Up @@ -430,7 +430,7 @@ jobs:
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: all_interfaces
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'all_interfaces.txt' || '' }}


Expand All @@ -441,7 +441,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).external-libraries-tests
Expand All @@ -463,7 +463,7 @@ jobs:
python_version: ${{ matrix.python-version }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: external
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
additional_pip_packages: |
pyzx matplotlib stim quimb==1.8.4 mitiq ply optax
git+https://github.com/PennyLaneAI/pennylane-qiskit.git@master
Expand All @@ -488,7 +488,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).qcut-tests
Expand All @@ -510,7 +510,7 @@ jobs:
python_version: ${{ matrix.python-version }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: qcut
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
additional_pip_packages: |
kahypar==1.1.7
opt_einsum
Expand All @@ -528,7 +528,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).qchem-tests
Expand All @@ -551,7 +551,7 @@ jobs:
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: qchem
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
additional_pip_packages: |
openfermionpyscf basis-set-exchange geometric
${{ inputs.additional_python_packages }}
Expand All @@ -563,7 +563,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).gradients-tests
Expand All @@ -586,7 +586,7 @@ jobs:
branch: ${{ inputs.branch }}
coverage_artifact_name: gradients-${{ matrix.config.suite }}-coverage
python_version: ${{ matrix.python-version }}
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
additional_pip_packages: |
${{ needs.default-dependency-versions.outputs.jax-version }}
${{ needs.default-dependency-versions.outputs.tensorflow-version }}
Expand All @@ -604,7 +604,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).data-tests
Expand All @@ -626,7 +626,7 @@ jobs:
python_version: ${{ matrix.python-version }}
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_additional_args: -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}
pytest_markers: data
additional_pip_packages: |
h5py
Expand All @@ -640,7 +640,7 @@ jobs:
- default-dependency-versions
- disable-fail-fast-wae
strategy:
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'default' }}
fail-fast: ${{ needs.disable-fail-fast-wae.outputs.fail_fast == 'yes' }}
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).device-tests
Expand Down Expand Up @@ -675,7 +675,7 @@ jobs:
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
pytest_test_directory: pennylane/devices/tests
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_additional_args: --device=${{ matrix.config.device }} --shots=${{ matrix.config.shots }} -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }}
pytest_additional_args: --device=${{ matrix.config.device }} --shots=${{ matrix.config.shots }} ${{ inputs.warnings_as_errors == 'true' && '-W error --continue-on-collection-errors' || '' }}


upload-to-codecov:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package_warnings_as_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: ./.github/workflows/interface-unit-tests.yml
with:
branch: ${{ github.ref }}
python_warning_level: 'error'
warnings_as_errors: true
run_lightened_ci: false
skip_ci_test_jobs: |
tf-tests
Expand Down
4 changes: 2 additions & 2 deletions pennylane/devices/default_clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
return "default.clifford"

# pylint:disable = too-many-arguments
def __init__(

Check notice on line 396 in pennylane/devices/default_clifford.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/devices/default_clifford.py#L396

Too many positional arguments (7/5) (too-many-positional-arguments)
self,
wires=None,
shots=None,
Expand Down Expand Up @@ -577,7 +577,7 @@
self._apply_snapshot(circuit, stim_circuit, op, global_phase_ops, debugger)

tableau_simulator.do_circuit(stim_circuit)
global_phase = qml.GlobalPhase(qml.math.sum(op.data[0] for op in global_phase_ops))
global_phase = qml.GlobalPhase(qml.math.sum([op.data[0] for op in global_phase_ops]))

# Perform measurments based on whether shots are provided
if circuit.shots:
Expand Down Expand Up @@ -613,7 +613,7 @@
ShadowExpvalMP: self._sample_expval_shadow,
}

def _apply_snapshot(

Check notice on line 616 in pennylane/devices/default_clifford.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/devices/default_clifford.py#L616

Too many positional arguments (6/5) (too-many-positional-arguments)
self,
circuit: qml.tape.QuantumScript,
stim_circuit,
Expand All @@ -636,7 +636,7 @@
if self.wires is not None:
snap_sim.set_num_qubits(len(self.wires))
snap_sim.do_circuit(stim_circuit)
global_phase = qml.GlobalPhase(qml.math.sum(op.data[0] for op in global_phase_ops))
global_phase = qml.GlobalPhase(qml.math.sum([op.data[0] for op in global_phase_ops]))

snap_result = measurement_func(
meas,
Expand Down
4 changes: 2 additions & 2 deletions pennylane/ops/qubit/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def compute_matrix(basis_state: TensorLike) -> np.ndarray: # pylint: disable=ar
for i, m in enumerate(basis_state):
idx = idx + (m << (len(basis_state) - i - 1))
mat = qml.math.zeros(shape, like=basis_state)
return mat.at[idx, idx].set(1.0)
return mat.at[idx, idx].set(1)

m = np.zeros(shape)
idx = int("".join(str(i) for i in basis_state), 2)
Expand Down Expand Up @@ -617,7 +617,7 @@ def compute_eigvals(basis_state: TensorLike) -> np.ndarray: # pylint: disable=a
for i, m in enumerate(basis_state):
idx = idx + (m << (len(basis_state) - i - 1))
eigvals = qml.math.zeros(2 ** len(basis_state), like=basis_state)
return eigvals.at[idx].set(1.0)
return eigvals.at[idx].set(1)
w = np.zeros(2 ** len(basis_state))
idx = int("".join(str(i) for i in basis_state), 2)
w[idx] = 1
Expand Down
10 changes: 5 additions & 5 deletions pennylane/resource/first_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
num_wires = AnyWires
grad_method = None

def __init__(

Check notice on line 85 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L85

Too many positional arguments (8/5) (too-many-positional-arguments)
self,
n,
eta,
Expand Down Expand Up @@ -118,7 +118,7 @@
/ self.omega
* np.array([np.cross(vectors[i], vectors[j]) for i, j in [(1, 2), (2, 0), (0, 1)]])
)
bbt = np.matrix(recip_vectors) @ np.matrix(recip_vectors).T
bbt = np.array(recip_vectors) @ np.array(recip_vectors).T
self.cubic = np.linalg.norm(bbt - (recip_vectors**2).max() * np.identity(3)) < 1e-6

self.lamb = self.norm(
Expand Down Expand Up @@ -190,7 +190,7 @@
return p

@staticmethod
def norm(n, eta, omega, error, br=7, charge=0, cubic=True, vectors=None):

Check notice on line 193 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L193

Too many positional arguments (8/5) (too-many-positional-arguments)
r"""Return the 1-norm of a first-quantized Hamiltonian in the plane-wave basis.

The expressions needed for computing the norm are taken from
Expand Down Expand Up @@ -389,7 +389,7 @@
return min(cost_f, cost_c)

@staticmethod
def unitary_cost(n, eta, omega, error, br=7, charge=0):

Check notice on line 392 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L392

Too many positional arguments (6/5) (too-many-positional-arguments)
r"""Return the number of Toffoli gates needed to implement the qubitization unitary
operator.

Expand Down Expand Up @@ -475,7 +475,7 @@
return int(np.ceil(cost))

@staticmethod
def estimation_cost(n, eta, omega, error, br=7, charge=0, cubic=True, vectors=None):

Check notice on line 478 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L478

Too many positional arguments (8/5) (too-many-positional-arguments)
r"""Return the number of calls to the unitary needed to achieve the desired error in quantum
phase estimation.

Expand Down Expand Up @@ -523,7 +523,7 @@
return int(np.ceil(np.pi * lamb / (2 * error_qpe)))

@staticmethod
def gate_cost(n, eta, omega, error, br=7, charge=0, cubic=True, vectors=None):

Check notice on line 526 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L526

Too many positional arguments (8/5) (too-many-positional-arguments)
r"""Return the total number of Toffoli gates needed to implement the first quantization
algorithm.

Expand Down Expand Up @@ -582,7 +582,7 @@
return e_cost * u_cost

@staticmethod
def qubit_cost(n, eta, omega, error, br=7, charge=0, cubic=True, vectors=None):

Check notice on line 585 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L585

Too many positional arguments (8/5) (too-many-positional-arguments)
r"""Return the number of logical qubits needed to implement the first quantization
algorithm.

Expand Down Expand Up @@ -668,7 +668,7 @@
return int(np.ceil(qubits))

@staticmethod
def _norm_noncubic(

Check notice on line 671 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L671

Too many positional arguments (6/5) (too-many-positional-arguments)
n,
eta,
error,
Expand Down Expand Up @@ -699,7 +699,7 @@
* np.array([np.cross(vectors[i], vectors[j]) for i, j in [(1, 2), (2, 0), (0, 1)]])
)

bbt = np.matrix(recip_vectors) @ np.matrix(recip_vectors).T
bbt = np.array(recip_vectors) @ np.array(recip_vectors).T

orthogonal = (
np.linalg.norm(bbt - np.array([np.max(b**2) for b in recip_vectors]) * np.identity(3))
Expand Down Expand Up @@ -769,7 +769,7 @@
lambda_u_1 = lambda_u * lambda_nu_1 / lambda_nu
lambda_v_1 = lambda_v * lambda_nu_1 / lambda_nu

b_mat = np.matrix(recip_vectors)
b_mat = np.array(recip_vectors)
abs_sum = np.abs(b_mat @ b_mat.T).flatten().sum()

# taken from Appendix I.1 of arXiv:2302.07981v1 (2023)
Expand All @@ -794,7 +794,7 @@
return ((lambda_u_1 + lambda_v_1 / (1 - 1 / eta)) / p_nu_amp) / p_eq, aa_steps

@staticmethod
def _qubit_cost_noncubic(n, eta, error, br, charge, vectors):

Check notice on line 797 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L797

Too many positional arguments (6/5) (too-many-positional-arguments)
r"""Return the number of logical qubits needed to implement the first quantization
algorithm for non-cubic systems.

Expand Down Expand Up @@ -886,7 +886,7 @@
* np.pi
* eta
* 2 ** (2 * n_p - 2)
* np.abs(np.matrix(recip_vectors) @ np.matrix(recip_vectors).T).flatten().sum()
* np.abs(np.array(recip_vectors) @ np.array(recip_vectors).T).flatten().sum()
/ error_b
)
)
Expand All @@ -895,7 +895,7 @@
return int(np.ceil(clean_cost))

@staticmethod
def _unitary_cost_noncubic(n, eta, error, br, charge, vectors):

Check notice on line 898 in pennylane/resource/first_quantization.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/resource/first_quantization.py#L898

Too many positional arguments (6/5) (too-many-positional-arguments)
r"""Return the number of Toffoli gates needed to implement the qubitization unitary
operator for non-cubic systems.

Expand Down Expand Up @@ -981,7 +981,7 @@
* np.pi
* eta
* 2 ** (2 * n_p - 2)
* np.abs(np.matrix(recip_vectors) @ np.matrix(recip_vectors).T).flatten().sum()
* np.abs(np.array(recip_vectors) @ np.array(recip_vectors).T).flatten().sum()
/ error_b
)
)
Expand Down
2 changes: 1 addition & 1 deletion pennylane/templates/subroutines/qsvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ def circuit_qsvt():
raise AssertionError("The polynomial must have at least degree 1.")

for x in [-1, 0, 1]:
if qml.math.abs(qml.math.sum(coeff * x**i for i, coeff in enumerate(poly))) > 1:
if qml.math.abs(qml.math.sum([coeff * x**i for i, coeff in enumerate(poly)])) > 1:
# Check that |P(x)| ≤ 1. Only points -1, 0, 1 will be checked.
raise AssertionError("The polynomial must satisfy that |P(x)| ≤ 1 for all x in [-1, 1]")

Expand Down
4 changes: 2 additions & 2 deletions tests/data/attributes/test_molecule_.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"""


import numpy as np
import pytest

from pennylane import numpy as pnp
from pennylane.data.attributes.molecule import DatasetMolecule
from pennylane.data.base.typing_util import get_type_str
from pennylane.qchem import Molecule
Expand Down Expand Up @@ -51,7 +51,7 @@ def _assert_molecules_equal(mol_in: Molecule, mol_out: Molecule):
@pytest.mark.parametrize(
("symbols", "coordinates"),
[
(["H", "F"], np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]])),
(["H", "F"], pnp.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]])),
],
)
class TestDatasetMolecule:
Expand Down
3 changes: 2 additions & 1 deletion tests/devices/default_qubit/test_default_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2239,5 +2239,6 @@ def circuit(params):

circuit_qml = qml.QNode(circuit, qml.device("default.qubit", shots=1000), interface="jax")

circuit_qml(params)
with pytest.warns(UserWarning, match="Explicitly requested dtype <class 'jax.numpy.int64'>"):
circuit_qml(params)
jax.config.update("jax_enable_x64", initial_mode)
Loading
Loading