Fix QuantumCircuit.draw without matplotlib installed#8737
Fix QuantumCircuit.draw without matplotlib installed#8737mergify[bot] merged 2 commits intoQiskit:mainfrom
Conversation
A recent change to the structure of the visualisation module in Qiskit#8306 caused `matplotlib` to be eagerly imported when `qiskit.visualization` was imported, since the internal `bloch` module was imported in the `__init__`. This means that `QuantumCircuit.draw()` in text mode had ceased working without the visualisation extra installed. This module doesn't really need to be eagerly imported, and it's faffy to refactor it all to use lazy imports.
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
|
Yeah, those shouldn't have been in the top level both because of potentially dragging mpl in to the import too early without an optional check, but also we don't want to re-xport those as part of the interface |
Pull Request Test Coverage Report for Build 3047539200
💛 - Coveralls |
Summary
A recent change to the structure of the visualisation module in #8306 caused
matplotlibto be eagerly imported whenqiskit.visualizationwas imported, since the internalblochmodule was imported in the__init__. This means thatQuantumCircuit.draw()in text mode had ceased working without the visualisation extra installed.This module doesn't really need to be eagerly imported, and it's faffy to refactor it all to use lazy imports.
Details and comments
I've seen a couple of CI failures in the QPY backwards-compatibility tests seemingly caused by this. It's odd they didn't prevent the initial merge, but maybe some internal dependencies re-organised themselves around the same time.