Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More carefully track the state of the matplotlib figure and axes used by
Bloch sphere. Previously .render(...) took fig and axes arguments and overwrote self.fig and self.axes if the arguments were None. The actual values of the arguments were completely discarded (!!). In addition, not supplying a value for fig and axes would overwrite the values passed to the constructor as Bloch(..., fig=fig, axes=axes). The new behaviour is as follows: * If an external figure is passed to the constructor it is retained. * If no figure is supplied, .render() will create a figure if one has not been created yet, or if the figure has been closed, will recreate it. * .render() will always call self.fig.canvas.update() to ensure that any existing figure that is already shown will be updated. Previously it was possible to cause .render() to raise obscure exceptions by, e.g., calling .render(), closing the figure, calling .render() again. See, for example, qutip#1616. The external figure tracking was backported from Qiskit's copy of Bloch and was inspired by PR Qiskit/qiskit#1091.
- Loading branch information