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

Non-integer indices in imshow_with_mouseover causing abundance of DeprecationWarnings #53

Closed
mperrin opened this issue Aug 23, 2018 · 3 comments
Labels
bug Something isn't working pr-opened priority:low

Comments

@mperrin
Copy link
Collaborator

mperrin commented Aug 23, 2018

Issue by josePhoenix
Monday Jan 26, 2015 at 22:07 GMT
Originally opened as mperrin/poppy#53


@kvangorkom reports that recent versions of NumPy emit a deprecation warning when arrays are indexed with non-integer indices. The formatter in imshow_with_mouseover seems to do a lot of this, emitting a DeprecationWarning on every mouse movement.

In [1]: import warnings, exceptions

In [2]: warnings.filterwarnings("error",category=exceptions.DeprecationWarning)

In [3]: import webbpsf
WebbPSF log messages of level INFO and above will be shown.
WebbPSF log outputs will be directed to the screen.

In [4]: nircam = webbpsf.NIRCam()
#...
In [6]: import matplotlib.pyplot as plt
#...
In [8]: plt.ion() #I don't remember having to explicitly declare this to get display to show up? Whatevs.

In [9]: nircam.display()
webbpsf   : INFO     Creating optical system model:
poppy     : INFO     Initialized OpticalSystem: JWST+NIRCam
poppy     : INFO     JWST Pupil: Loaded amplitude transmission from /Users/kgorkom/webbpsf-data/pupil_RevV.fits
poppy     : INFO     JWST Pupil: Loaded OPD from /Users/kgorkom/webbpsf-data//NIRCam/OPD/OPD_RevV_nircam_155.fits
poppy     : INFO     The supplied pupil OPD is a datacube but no slice was specified. Defaulting to use slice 0.
poppy     : INFO     Added pupil plane: JWST Pupil
poppy     : INFO     Added detector: NIRCam detector, with pixelscale=0.031700 arcsec/pixel and oversampling=2
poppy     : INFO     Displaying plane JWST Pupil in row 1 of 1

#Mouse over the plots

In [10]: Exception in Tkinter callback
Traceback (most recent call last):
  File "/Users/kgorkom/STScI/ssbx/python/lib/python2.7/lib-tk/Tkinter.py", line 1470, in __call__
    return self.func(*args)
  File "/Users/kgorkom/STScI/ssbx/python/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.6-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 380, in motion_notify_event
    FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
  File "/Users/kgorkom/STScI/ssbx/python/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.6-x86_64.egg/matplotlib/backend_bases.py", line 1834, in motion_notify_event
    self.callbacks.process(s, event)
  File "/Users/kgorkom/STScI/ssbx/python/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.6-x86_64.egg/matplotlib/cbook.py", line 527, in process
    proxy(*args, **kwargs)
  File "/Users/kgorkom/STScI/ssbx/python/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.6-x86_64.egg/matplotlib/cbook.py", line 405, in __call__
    return mtd(*args, **kwargs)
  File "/Users/kgorkom/STScI/ssbx/python/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.6-x86_64.egg/matplotlib/backend_bases.py", line 2788, in mouse_move
    s = event.inaxes.format_coord(event.xdata, event.ydata)
  File "/Users/kgorkom/STScI/ssbx/variants/common/src/poppy/poppy/utils.py", line 57, in <lambda>
    np.floor( (x - imext[0])/(imext[1]-imext[0])*imsize[1]  ).clip(0,imsize[1]-1)])
  File "/Users/kgorkom/STScI/ssbx/variants/common/lib/python2.7/site-packages/numpy/ma/core.py", line 2999, in __getitem__
    dout = ndarray.__getitem__(_data, indx)
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
@mperrin
Copy link
Collaborator Author

mperrin commented Aug 23, 2018

Comment by mperrin
Monday Jan 26, 2015 at 23:49 GMT


This is perhaps related to a feature of astropy where it converts DeprecationWarnings into Errors in some cases. See astropy/astropy#2502

In any case we should fix this the right way in the code. In imshow_with_mousover, the code is already calling np.floor() on the results, but it's returning them as floats which still triggers this DeprecationWarning despite having an integer numeric value. Simple fix to add a cast to int there. I'd do it myself except trying to not multitask too much while at Gemini. Thanks.

@mperrin mperrin added bug Something isn't working pr-opened priority:low labels Aug 23, 2018
@mperrin
Copy link
Collaborator Author

mperrin commented Aug 23, 2018

Comment by josePhoenix
Tuesday Jan 27, 2015 at 00:38 GMT


Oh, I had Kyle promote warnings to errors so he could figure out where this was happening. The 'bug', such as it is, is that every mouse move event generates a new DeprecationWarning, drowning his terminal in output.

It's a low priority issue, but I wanted to put it in so I don't forget about it.

@mperrin
Copy link
Collaborator Author

mperrin commented Aug 23, 2018

Comment by mperrin
Wednesday Feb 11, 2015 at 04:01 GMT


Do we want to include this in this current release?

@mperrin mperrin closed this as completed Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pr-opened priority:low
Projects
None yet
Development

No branches or pull requests

1 participant