Skip to content
5 changes: 3 additions & 2 deletions qiskit/pulse/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ def _validate_index(self, index: Any) -> None:
raise PulseError('Channel index must be a nonnegative integer')

@property
@deprecated_functionality
def parameters(self) -> Set:
"""Parameters which determine the channel index."""
return self._parameters
if isinstance(self.index, ParameterExpression):
return self.index.parameters
return set()

def is_parameterized(self) -> bool:
"""Return True iff the channel is parameterized."""
Expand Down
8 changes: 6 additions & 2 deletions qiskit/pulse/instructions/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,14 @@ def append(self, schedule,
return self.insert(time, schedule, name=name)

@property
@deprecated_functionality
def parameters(self) -> Set:
"""Parameters which determine the instruction behavior."""
return set(self._parameter_table.keys())
parameters = set()
for op in self.operands:
if hasattr(op, 'parameters'):
for op_param in op.parameters:
parameters.add(op_param)
return parameters

def is_parameterized(self) -> bool:
"""Return True iff the instruction is parameterized."""
Expand Down
16 changes: 15 additions & 1 deletion qiskit/pulse/instructions/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""An instruction to transmit a given pulse on a ``PulseChannel`` (i.e., those which support
transmitted pulses, such as ``DriveChannel``).
"""
from typing import Dict, Optional, Union, Tuple, Any
from typing import Dict, Optional, Union, Tuple, Any, Set

from qiskit.circuit.parameterexpression import ParameterExpression, ParameterValueType
from qiskit.pulse.channels import PulseChannel
Expand Down Expand Up @@ -93,6 +93,20 @@ def _initialize_parameter_table(self,
# Table maps parameter to operand index, 0 for ``pulse``
self._parameter_table[param].append(0)

@property
def parameters(self) -> Set:
"""Parameters which determine the instruction behavior."""
parameters = set()
for pulse_param_expr in self.pulse.parameters.values():
if isinstance(pulse_param_expr, ParameterExpression):
for pulse_param in pulse_param_expr.parameters:
parameters.add(pulse_param)
if self.channel.is_parameterized():
for ch_param in self.channel.parameters:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that the tests need to be extended with parametrised channels: https://coveralls.io/builds/39061954/source?filename=qiskit%2Fpulse%2Finstructions%2Fplay.py#L105

parameters.add(ch_param)

return parameters

@deprecated_functionality
def assign_parameters(self,
value_dict: Dict[ParameterExpression, ParameterValueType]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
other:
- |
Deprecation warning for :meth:`~qiskit.pulse.Instruction.parameters` is dropped.
This method will continue to be supported.