quiver warnings

Hi! Bumping this upstream from Sage, where we use quiver to draw
slope fields. The following code

···

###
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
r = np.arange(10)
X,Y = np.meshgrid(r,r)
U, V = np.cos(X), np.sin(Y)
Q = plt.quiver( U, V, headlength=0, headaxislength=0)
###

produces exactly what we want, but generates some warnings:

/usr/local/lib/python2.7/dist-packages/matplotlib/quiver.py:622:
RuntimeWarning: divide by zero encountered in divide
  shrink = length/minsh
/usr/local/lib/python2.7/dist-packages/matplotlib/quiver.py:623:
RuntimeWarning: invalid value encountered in multiply
  X0 = shrink * X0[np.newaxis,:]
/usr/local/lib/python2.7/dist-packages/matplotlib/quiver.py:624:
RuntimeWarning: invalid value encountered in multiply
  Y0 = shrink * Y0[np.newaxis,:]

We can get around this by using some tiny headlength (minsh =
self.minshaft * self.headlength) but it seems more natural to avoid
drawing one entirely. Would there be any objections to a pull request
which special-cased 0 to avoid this?

Doug

Hi! Bumping this upstream from Sage, where we use quiver to draw
slope fields. The following code

###
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
r = np.arange(10)
X,Y = np.meshgrid(r,r)
U, V = np.cos(X), np.sin(Y)
Q = plt.quiver( U, V, headlength=0, headaxislength=0)
###

produces exactly what we want, but generates some warnings:

/usr/local/lib/python2.7/dist-packages/matplotlib/quiver.py:622:
RuntimeWarning: divide by zero encountered in divide
   shrink = length/minsh
/usr/local/lib/python2.7/dist-packages/matplotlib/quiver.py:623:
RuntimeWarning: invalid value encountered in multiply
   X0 = shrink * X0[np.newaxis,:]
/usr/local/lib/python2.7/dist-packages/matplotlib/quiver.py:624:
RuntimeWarning: invalid value encountered in multiply
   Y0 = shrink * Y0[np.newaxis,:]

We can get around this by using some tiny headlength (minsh =
self.minshaft * self.headlength) but it seems more natural to avoid
drawing one entirely. Would there be any objections to a pull request
which special-cased 0 to avoid this?

No objections at all; it sounds like a good idea.

Eric

···

On 03/11/2012 12:27 PM, D. S. McNeil wrote:

Doug

------------------------------------------------------------------------------
Virtualization& Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options