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

Fix deprecation warning for deprecated_functionality (backport #8851) #8886

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 20 additions & 4 deletions qiskit/pulse/transforms/alignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

import abc
from typing import Callable, Dict, Any, Union, Tuple
import warnings

import numpy as np

from qiskit.circuit.parameterexpression import ParameterExpression, ParameterValueType
from qiskit.pulse.exceptions import PulseError
from qiskit.pulse.schedule import Schedule, ScheduleComponent
from qiskit.pulse.utils import instruction_duration_validation, deprecated_functionality
from qiskit.pulse.utils import instruction_duration_validation


class AlignmentKind(abc.ABC):
Expand All @@ -44,9 +45,14 @@ def align(self, schedule: Schedule) -> Schedule:
"""
pass

@deprecated_functionality
def to_dict(self) -> Dict[str, Any]:
"""Returns dictionary to represent this alignment."""
warnings.warn(
"The AlignmentKind.to_dict method is deprecated as of Qiskit Terra "
"0.21 and will be removed no sooner than 3 months after the release date.",
category=DeprecationWarning,
stacklevel=2,
)
return {"alignment": self.__class__.__name__}

@property
Expand Down Expand Up @@ -329,9 +335,14 @@ def align(self, schedule: Schedule) -> Schedule:

return aligned

@deprecated_functionality
def to_dict(self) -> Dict[str, Any]:
"""Returns dictionary to represent this alignment."""
warnings.warn(
"The AlignEquispaced.to_dict method is deprecated as of Qiskit Terra "
"0.21 and will be removed no sooner than 3 months after the release date.",
category=DeprecationWarning,
stacklevel=2,
)
return {"alignment": self.__class__.__name__, "duration": self.duration}


Expand Down Expand Up @@ -413,12 +424,17 @@ def align(self, schedule: Schedule) -> Schedule:

return aligned

@deprecated_functionality
def to_dict(self) -> Dict[str, Any]:
"""Returns dictionary to represent this alignment.

.. note:: ``func`` is not presented in this dictionary. Just name.
"""
warnings.warn(
"The AlignFunc.to_dict method is deprecated as of Qiskit Terra "
"0.21 and will be removed no sooner than 3 months after the release date.",
category=DeprecationWarning,
stacklevel=2,
)
return {
"alignment": self.__class__.__name__,
"duration": self.duration,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
deprecations:
- |
The pulse-module function ``qiskit.pulse.utils.deprecate_functionality`` is
The pulse-module function ``qiskit.pulse.utils.deprecated_functionality`` is
deprecated and will be removed in a future release. This was a primarily
internal-only function. The same functionality is supplied by
``qiskit.utils.deprecate_function``, which should be used instead.