Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Add a parameters method to the operators #1090

Closed
Cryoris opened this issue Jul 1, 2020 · 5 comments
Closed

Add a parameters method to the operators #1090

Cryoris opened this issue Jul 1, 2020 · 5 comments
Labels
good first issue Good for newcomers type: feature request New feature or request

Comments

@Cryoris
Copy link
Contributor

Cryoris commented Jul 1, 2020

What is the expected behavior?

Calling QuantumCircuit.parameters returns a set of the Parameter objects in the circuit.
The OperatorBase should support this too, since it too can be parameterized.

@Cryoris Cryoris added the type: feature request New feature or request label Jul 1, 2020
@Cryoris Cryoris added the good first issue Good for newcomers label Jul 1, 2020
@techwithshadab
Copy link

Hi @Cryoris
Can you point me to the QuantumCircuit.parameters file?

@Cryoris
Copy link
Contributor Author

Cryoris commented Jul 21, 2020

It's a method here: https://github.com/Qiskit/qiskit-terra/blob/76f21b011171486ccc77775ea29f51be196755e2/qiskit/circuit/quantumcircuit.py#L1645

In an OperatorBase either the coefficients can be parameterized (ie of type ParameterExpression -- careful, this is not the same as a plain Parameter) or if it contains a CircuitOp or CircuitStateFn, the underlying circuit can be parameterized. You can probably recursively check these two and return a set of all Parameters you found,.

@VANRao-Stack
Copy link

It's a method here: https://github.com/Qiskit/qiskit-terra/blob/76f21b011171486ccc77775ea29f51be196755e2/qiskit/circuit/quantumcircuit.py#L1645
In an OperatorBase either the coefficients can be parameterized (ie of type ParameterExpression -- careful, this is not the same as a plain Parameter) or if it contains a CircuitOp or CircuitStateFn, the underlying circuit can be parameterized. You can probably recursively check these two and return a set of all Parameters you found,.

I see that the OperatorBase class can accept coefficients of different types like int, float etc. Is the code expected to return all those coefficients for this feature request? Also, if it does contain the ParamterExpression, is it supposed to return the ParamterExpression object?

@Cryoris
Copy link
Contributor Author

Cryoris commented Jul 27, 2020

It's supposed to only return the Parameter objects, no floats/ints. If you have a ParameterExpression you can get the Parameters it contains by ParameterExpression.parameters. Essentially the behaviour should be the same as for the QuantumCircuit and its parameters method 🙂

@woodsp-ibm
Copy link
Member

Closed as solved by #1194

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants