Skip to content

Commit

Permalink
Properly deprecate quadratic program ising converter classes (qiskit-…
Browse files Browse the repository at this point in the history
…community/qiskit-aqua#1178)

* Properly deprecate quadratic program ising converters

In qiskit-community/qiskit-aqua#1061 the ising converter classes were removed without a deprecation
period and then backported to the stable branch. This is a violation of
both the Qiskit deprecation policy [1] and the Qiskit stable branch
policy [2] and should not have been merged like that. This is preventing
the Qiskit metapackage 0.20.0 from being released because the tutorials
as written today do not work with aqua 0.7.4 because of this breaking
change. It should have been deprecated first for an appropriate period
to give users a chance to adjust their code and then removed. During
this period the tutorial could also be updated. This also should never
have been backported to stable since users expect a stable point release
to just contain bugfixes removals and deprecations should not be part of
stable releases. This commit adds back the removed classes and deprecates
them, this will need to be backported and released as 0.7.5. While
normally this deprecation would not be allowed under the backport policy
it is necessary here because we already released a breaking change.

[1] https://qiskit.org/documentation/contributing_to_qiskit.html#deprecation-policy
[2] https://qiskit.org/documentation/contributing_to_qiskit.html#stable-branch-policy

* Fix typo

* Remove broken loop

* Add missing print methods

Running through the tutorials there are more methods that have been
removed that needed to go through a proper deprecation, this commit
starts adding them back. There is still print_details() that needs to be
added back.

* add unit test

* Add print_details to SummedOp

This is needed for backwards compat with the optimziation code which
used to return a legacy WeightedPauliOp object. 'print_details()' is
used in the tutorials on the output from conversion so a deprecated
method is added to add this funcionality to gracefully move users over
to the new workflow.

* fix lint

* fix docstring

Co-authored-by: Manoel Marques <manoel.marques@ibm.com>
  • Loading branch information
mtreinish and manoelmarques authored Aug 7, 2020
1 parent 4f414a7 commit 89031ee
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qiskit/aqua/operators/list_ops/summed_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
""" SummedOp Class """

from typing import List, Union, cast
import warnings

import numpy as np

Expand Down Expand Up @@ -160,6 +161,19 @@ def to_legacy_op(self, massive: bool = False) -> LegacyBaseOperator:

return self.combo_fn(legacy_ops) * coeff

def print_details(self):
"""
Print out the operator in details.
Returns:
str: a formatted string describes the operator.
"""
warnings.warn("print_details() is deprecated and will be removed in "
"a future release. Instead you can use .to_legacy_op() "
"and call print_details() on it's output",
DeprecationWarning)
ret = self.to_legacy_op().print_details()
return ret

def equals(self, other: OperatorBase) -> bool:
"""Check if other is equal to self.
Expand Down

0 comments on commit 89031ee

Please sign in to comment.