[cctbxbb] Deprecation warning?
Graeme.Winter at diamond.ac.uk
Graeme.Winter at diamond.ac.uk
Wed Aug 8 01:17:32 PDT 2012
Hi Nat,
Interesting, here is the offending code
def plot_shoebox(shoebox):
'''
Render a shoebox as a sequence of png images using matplotlib.
'''
frame, slow, fast = shoebox.accessor().all()
max_value = 100
for j in range(frame):
from scitbx.array_family import flex
import numpy
import matplotlib
from matplotlib import pyplot
grid = flex.grid((slow, fast))
slice = flex.double(grid)
for s in range(slow):
for f in range(fast):
if shoebox[(j, s, f)] < 0:
slice[(s, f)] = max_value
else:
slice[(s, f)] = shoebox[(j, s, f)]
image = numpy.reshape(slice.as_numpy_array(), (slow, fast))
pyplot.imshow(image, cmap = matplotlib.cm.Greys, vmax = max_value,
interpolation = 'nearest', norm = None, filternorm = 0.0)
pyplot.savefig('frame%02d.png' % (j))
i.e. pretty similar to your example, and the error
Graemes-MacBook-Pro:cube graeme$ cctbx.python cube.py
/Users/graeme/svn/cctbx_plus/base/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py:1382: wxPyDeprecationWarning: Using deprecated class PySimpleApp.
wxapp = wx.PySimpleApp()
That said, I am using a home-brewed cctbx.python which should correspond to the cctbx plus build - I used the same script to make it as you guys use to make the python base.
I will add the deprecation-avoiding code you include below with a loud warning that really this should not be needed.
Thanks,
Graeme
On 7 Aug 2012, at 18:49, Nathaniel Echols wrote:
> On Tue, Aug 7, 2012 at 3:04 AM, <Graeme.Winter at diamond.ac.uk> wrote:
>> Is there a way to avoid this?
>>
>> Using matplotlib.pyplot.
>>
>> /Users/graeme/svn/cctbx_plus/base/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py:1382: wxPyDeprecationWarning: Using deprecated class PySimpleApp.
>> wxapp = wx.PySimpleApp()
>
> You can do this:
>
> import warnings
> warnings.filterwarnings("ignore", category=DeprecationWarning)
>
> But that's somewhat dangerous. How are you starting pyplot? I don't
> get this error when I try something trivial like this:
>
> nat at clover:~> phenix.wxpython
>>>> import matplotlib.pyplot as plt
>>>> f = plt.figure()
>>>> p = plt.plot([1,2,3],[4,5,6])
>>>> plt.show()
>
> But if I do this, I get the same warning:
>
>>>> import wx
>>>> app = wx.PySimpleApp()
> __main__:1: wxPyDeprecationWarning: Using deprecated class.
>
> So I suspect matplotlib is suppressing the warning somehow.
> Alternately, it looks as though if a wx.App instance has already been
> created, matplotlib will use that instead.
>
> -Nat
> _______________________________________________
> cctbxbb mailing list
> cctbxbb at phenix-online.org
> http://phenix-online.org/mailman/listinfo/cctbxbb
--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
More information about the cctbxbb
mailing list