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
New UI for passing Parameter values #406
Conversation
[sc-56075] |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #406 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 331 362 +31
=========================================
+ Hits 331 362 +31 ☔ View full report in Codecov by Sentry. |
To confirm, is this part a typo that should be |
Yes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lillian542! Looks great, just leaving some initial feedback.
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
Thanks @lillian542 @obliviateandsurrender! qml.from_qiskit(qc)(y, z, x) # order is alphabetical wrt parameter names Could we get the order to depend on the order specified in the Qiskit circuit? I worry that alphabetical could be less intuitive. >>> qml.from_qiskit(qc)(phi=0.2, psi=0.3)
TypeError: Missing 1 required argument to define Parameter values for: {Parameter(theta)} Would it make sense if it were instead >>> qml.from_qiskit(qc)(phi=0.2, psi=0.3, misspelled_kwarg=0.4)
TypeError: Got unexpected parameter keyword argument 'misspelled_kwarg'. Circuit contains parameters ParameterView([Parameter(phi), Parameter(psi), Parameter(theta)]) Not a huge blocker, but I'm not so keen on the repr for |
We could store them in the order they are used when defining and executing the Qiskit circuit. Here's why I didn't: The qiskit circuit stores parameters as
Let me know what you think. The order they are used is an option.
There's no motivation, it's just already a set when it gets to this point in the code, and I used it as is. I'll change them all to use just the names of the parameters. This also covers the final comment about the |
Ah I did mean to use the order specified by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some docs suggestions, the rest looks good to me!
pennylane_qiskit/converter.py
Outdated
raise TypeError( | ||
f"Expected {len(arg_parameters)} positional argument{'s' if len(arg_parameters) > 1 else ''} but {len(args)} were given" | ||
) | ||
params.update(dict(zip(arg_parameters, args))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does codefactor complain about this function? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So pylint and sourcery are definitely complaining about this file, but they don't seem to be concerned about this function. And it doesn't seem particularly nested or branchy to me... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if its placing the warning in the wrong place, since _function
is overly nested, branchy, and overall low code quality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to ignore it for now, looks like the CodeFactor check still passes, and there are quite a few changes to this function in the next PR - I don't really want to create a bunch of merge conflicts by moving things around here.
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
wires (Sequence[int] or int): The wires the converted template acts on. | ||
Note that if the original QuantumCircuit acted on :math:`N` qubits, | ||
then this must be a list of length :math:`N`. | ||
|
||
Returns: | ||
function: the new PennyLane template | ||
|
||
.. warning:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if its worth moving these warnings and examples into the docstring for load
, as that is the docstring that will render in the website.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we definitely want them here, because this is what you get if you "ask" the function what it does in Jupyter, i.e.
qfunc = qml.from_qiskit(qc)
qfunc?
I think we want something more extensive in qml.from_qiskit
, which will be the documentation on the PennyLane website. @trbromley , do we also want to expand documentation on the load
function in the plugin, or is that more internal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that you can query qfunc
in Jupyter and get that info! And yes we do want the from_qiskit
docs to be on point - though we can treat it as a follow up to revisit those docs. I think the load
function in the plugin can be made a copy of whatever is in from_qiskit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially may need to silence code factor, but my comments are purely optional and non-blocking. Looks like a much cleaner syntax :)
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com> Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Old UI continues to be supported:
or
but the new reccommended UI is also implemented, with options to pass as args, kwargs, or a combination:
If params are passed that don't match, we get clear errors for too many arguments:
for not enough arguments:
and unrecognized key word arguments: