Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Unpacking breaks for usual parameter vectors #486

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

MSRudolph
Copy link
Contributor

By looping for parameter in parameters, parameter can be a float. The current implementation breaks the function.

By looping `for parameter in parameters`, `parameter` can be a float. The current implementation breaks the function.
@MSRudolph MSRudolph requested a review from Shiro-Raven April 29, 2022 12:54
@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #486 (fbd1f81) into dev (15de61d) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##              dev     #486   +/-   ##
=======================================
  Coverage   94.43%   94.43%           
=======================================
  Files          85       85           
  Lines        6590     6590           
=======================================
  Hits         6223     6223           
  Misses        367      367           
Impacted Files Coverage Δ
src/python/zquantum/core/circuits/_generators.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15de61d...fbd1f81. Read the comment docs.

Copy link
Contributor

@mstechly mstechly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test which checks this behaviour?
Also, I think it might not work if the parameters are sympy symbols, could you also check for that?

Copy link
Contributor

@AthenaCaesura AthenaCaesura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, shouldn't mypy take care of this? If parameter isn't an array (at least 1d) then you should get a mypy error.

@MSRudolph
Copy link
Contributor Author

mypy doesn't notice, because parameters: np.ndarray doesn't have a specified dimensionality. Try this:

from zquantum.core.circuits import Circuit, RX, apply_gate_to_qubits
apply_gate_to_qubits(Circuit(), (0, 1), RX, np.array([1, 2]))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants