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

matplotlib 3.4 issues new deprecation warnings #1503

Closed
jakelishman opened this issue Apr 19, 2021 · 1 comment · Fixed by #1556
Closed

matplotlib 3.4 issues new deprecation warnings #1503

jakelishman opened this issue Apr 19, 2021 · 1 comment · Fixed by #1556
Labels
BUG good first issue unitaryhack This issue is selected for participation in UnitaryHACK. unitaryhack-accepted This bounty for this UnitaryHack issue should be paid.

Comments

@jakelishman
Copy link
Member

matplotlib 3.4 has begun issuing some new deprecation warnings against some of the stuff we do in bloch.py.

Simple reproducer from within ipython --matplotlib:

In [1]: import qutip
   ...: b = qutip.Bloch()
   ...: b.add_vectors([0, 1, 0])
   ...: b.render()

produces

/Users/jake/.anaconda3/envs/qutip/lib/python3.9/site-packages/qutip/bloch.py:451: MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes.
  self.axes = Axes3D(self.fig, azim=self.view[0], elev=self.view[1])

/Users/jake/.anaconda3/envs/qutip/lib/python3.9/site-packages/qutip/bloch.py:59: MatplotlibDeprecationWarning:
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)

This particular environment had matplotlib==3.4.1.

The warnings themselves suggest fixes, however some care needs to be taken; I suspect that the additional keyword auto_add_to_figure might be new in matplotlib 3.4 (not sure about the .M attribute). We want to keep compatibility with at least matplotlib>=3 (we don't want to picky so it's easy to use QuTiP with other packages), so it might be necessary to include a version test using packaging.version.parse. If someone could test whether that's necessary, that'd be great.

@hodgestar hodgestar added the unitaryhack This issue is selected for participation in UnitaryHACK. label Apr 30, 2021
@hodgestar
Copy link
Contributor

Confirming that auto_add_to_figure is new in matplotlib 3.4.

@hodgestar hodgestar added the unitaryhack-accepted This bounty for this UnitaryHack issue should be paid. label May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG good first issue unitaryhack This issue is selected for participation in UnitaryHACK. unitaryhack-accepted This bounty for this UnitaryHack issue should be paid.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants