Skip to content

Fix wcsaxes warnings in Sphinx build - #6002

Closed
pllim wants to merge 1 commit into
astropy:masterfrom
pllim:fix-wcsaxes-warn
Closed

pllim wants to merge 1 commit into
astropy:masterfrom
pllim:fix-wcsaxes-warn

Conversation

@pllim

@pllim pllim commented May 3, 2017 •

Copy link
Copy Markdown
Member

This removes RuntimeWarning from wcsaxes in Sphinx build test log. This was part of #5997 but then taken out here. Also see #5992 (comment).

@astrofrog I don't know how to add regression test to visualization code, so I am making it raise an exception instead and then see what value is causing the warning in the first place. Maybe this will give us a clue on the proper fix.

TODO:

  • Add milestone.
  • Do we need change log for this?

@pllim
pllim requested a review from astrofrog May 3, 2017 17:15
@pllim pllim mentioned this pull request May 3, 2017
@pllim
pllim force-pushed the fix-wcsaxes-warn branch 2 times, most recently from 3587080 to 7033dd4 Compare May 4, 2017 19:24
@pllim

pllim commented May 4, 2017

Copy link
Copy Markdown
Member Author

Found the culprit (actually there are 2). @astrofrog , now that you have the traceback, what would be your recommendation as a proper fix?

/home/travis/build/astropy/astropy/docs/visualization/wcsaxes/custom_frames.rst:10: WARNING: Exception occurred in plotting custom_frames-1

 from /home/travis/build/astropy/astropy/docs/visualization/wcsaxes/custom_frames.rst:

Traceback (most recent call last):

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/sphinxext/plot_directive.py", line 651, in render_figures

    figman.canvas.figure.savefig(img.filename(format), dpi=dpi)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/figure.py", line 1573, in savefig

    self.canvas.print_figure(*args, **kwargs)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2200, in print_figure

    **kwargs)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 545, in print_png

    FigureCanvasAgg.draw(self)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 464, in draw

    self.figure.draw(self.renderer)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper

    draw(artist, renderer, *args, **kwargs)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/figure.py", line 1144, in draw

    renderer, self, dsu, self.suppressComposite)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images

    a.draw(renderer)

  File "/home/travis/build/astropy/astropy/build/lib.linux-x86_64-3.6/astropy/visualization/wcsaxes/core.py", line 341, in draw

    ticklabels_bbox=self._ticklabels_bbox)

  File "/home/travis/build/astropy/astropy/build/lib.linux-x86_64-3.6/astropy/visualization/wcsaxes/coordinate_helpers.py", line 438, in _draw

    ticklabels_bbox=ticklabels_bbox)

  File "/home/travis/build/astropy/astropy/build/lib.linux-x86_64-3.6/astropy/visualization/wcsaxes/ticklabels.py", line 187, in draw

    'calculations: {}'.format(dist))

ValueError: Invalid denominator for tick label calculations: 0.0
/home/travis/build/astropy/astropy/docs/visualization/wcsaxes/custom_frames.rst:37: WARNING: Exception occurred in plotting custom_frames-2

 from /home/travis/build/astropy/astropy/docs/visualization/wcsaxes/custom_frames.rst:

Traceback (most recent call last):

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/sphinxext/plot_directive.py", line 651, in render_figures

    figman.canvas.figure.savefig(img.filename(format), dpi=dpi)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/figure.py", line 1573, in savefig

    self.canvas.print_figure(*args, **kwargs)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2200, in print_figure

    **kwargs)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 545, in print_png

    FigureCanvasAgg.draw(self)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 464, in draw

    self.figure.draw(self.renderer)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper

    draw(artist, renderer, *args, **kwargs)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/figure.py", line 1144, in draw

    renderer, self, dsu, self.suppressComposite)

  File "/home/travis/miniconda/envs/test/lib/python3.6/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images

    a.draw(renderer)

  File "/home/travis/build/astropy/astropy/build/lib.linux-x86_64-3.6/astropy/visualization/wcsaxes/core.py", line 341, in draw

    ticklabels_bbox=self._ticklabels_bbox)

  File "/home/travis/build/astropy/astropy/build/lib.linux-x86_64-3.6/astropy/visualization/wcsaxes/coordinate_helpers.py", line 438, in _draw

    ticklabels_bbox=ticklabels_bbox)

  File "/home/travis/build/astropy/astropy/build/lib.linux-x86_64-3.6/astropy/visualization/wcsaxes/ticklabels.py", line 187, in draw

    'calculations: {}'.format(dist))

ValueError: Invalid denominator for tick label calculations: 0.0

@bsipocz

bsipocz commented May 10, 2017

Copy link
Copy Markdown
Member

@pllim - Could you make this ready for final review? It would have the advantage that I can make sure @astrofrog review this while we're both here...

@pllim pllim added this to the v2.0.0 milestone May 10, 2017
@pllim
pllim force-pushed the fix-wcsaxes-warn branch from 7033dd4 to 46c6a38 Compare May 10, 2017 15:11
@pllim pllim changed the title [WIP] Fix wcsaxes warnings in Sphinx build Fix wcsaxes warnings in Sphinx build May 10, 2017
@pllim

pllim commented May 10, 2017

Copy link
Copy Markdown
Member Author

@bsipocz , rebased and added change log (I feel like this is a bug fix) for v2.0. If @astrofrog thinks the default is reasonable, feel free to merge. I don't think it is critical bug to warrant a 1.3.3 tag. Basically we need to handle cases where dist == 0.

@pllim

pllim commented May 11, 2017

Copy link
Copy Markdown
Member Author

Someone please corner @astrofrog over there in Leiden and make him review this. 😂

@bsipocz

bsipocz commented May 11, 2017

Copy link
Copy Markdown
Member

@pllim - Already did that, he promised to have a look :)

@astrofrog

Copy link
Copy Markdown
Member

I'm investigating this - I'm not satisfied with the fix for now since I don't understand why this happens - this indicates somehow that the bounding box is a point, which seems... weird.

@astrofrog

Copy link
Copy Markdown
Member

Minimal example to reproduce the warning:

from astropy.wcs import WCS
from astropy.io import fits
from astropy.utils.data import get_pkg_data_filename
from astropy.visualization.wcsaxes.frame import EllipticalFrame
import matplotlib.pyplot as plt

filename = get_pkg_data_filename('galactic_center/gc_msx_e.fits')
hdu = fits.open(filename)[0]
wcs = WCS(hdu.header)

ax = plt.subplot(projection=wcs, frame_class=EllipticalFrame)
plt.savefig('test.png')

@astrofrog

Copy link
Copy Markdown
Member

Investigating how to properly fix...

@pllim

pllim commented May 12, 2017

Copy link
Copy Markdown
Member Author

Superseded by #6063.

@pllim pllim closed this May 12, 2017
@pllim
pllim deleted the fix-wcsaxes-warn branch May 12, 2017 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants