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

marginal_counts is using deprecated functionality #13084

Closed
eendebakpt opened this issue Sep 4, 2024 · 3 comments
Closed

marginal_counts is using deprecated functionality #13084

eendebakpt opened this issue Sep 4, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@eendebakpt
Copy link
Contributor

Environment

  • Qiskit version: 1.2.0
  • Python version: 3.12
  • Operating system: Windows

What is happening?

The qiskit marginal_counts method uses deprecated functionality when a Result object is used as input.

How can we reproduce the issue?

from qiskit.circuit import QuantumCircuit
from qiskit.result.utils import marginal_counts
from qiskit_aer import AerSimulator
import qiskit_aer
qiskit_aer.__version__

import warnings
warnings.simplefilter('default')

qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure_all()

backend = AerSimulator()
result = backend.run(qc, shots=100, memory=False).result()
result = marginal_counts(result, [0])

# qiskit 1.2.0
# qiskit_aer: 0.15.0

What should happen?

No warnings should be generated, but instead the output is

C:\develop\Python312\Lib\copy.py:434: DeprecationWarning: The class ``qiskit.qobj.common.QobjDictField`` is deprecated as of qiskit 1.2. It will be removed in the 2.0 release. The `Qobj` class and related functionality are part of the deprecated `BackendV1` workflow,  and no longer necessary for `BackendV2`. If a user workflow requires `Qobj` it likely relies on deprecated functionality and should be updated to use `BackendV2`.
  y = func(*args)

Any suggestions?

No response

@eendebakpt eendebakpt added the bug Something isn't working label Sep 4, 2024
@1ucian0
Copy link
Member

1ucian0 commented Sep 13, 2024

hmm... std copy raises this warning. Maybe @jakelishman knows what's going on.

@jakelishman
Copy link
Member

All of these warnings have their stack levels set correctly so that they do not blame user code. Setting the warnings to "show all warnings despite the filters" does show additional warnings, but there is some degree to which this is expected when deprecated functionality is in the process of being removed.

Fwiw, the actual deprecated functionality coming from the Result object that Aer is producing - the trouble is that Aer is still putting various deprecated Qobj things in its Result object, which are then dutifully deepcopyed. Qiskit isn't actually using deprecated functionality, the problem is just that it's deepcopying some deprecated objects that Aer actually created.

@eendebakpt
Copy link
Contributor Author

This indeed seems like an issue with qiskit-aer using deprecated functionality. I created Qiskit/qiskit-aer#2233 and will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants