mantid icon indicating copy to clipboard operation
mantid copied to clipboard

Unhandled exception when setting log axis on negative values

Open thomashampson opened this issue 3 years ago • 1 comments

Describe the bug When attempting to set an axis to log on a colourfill where the axis values are negtive, there is an unhandled exception:

Traceback (most recent call last):
  File "/opt/Mantid/lib/workbench/plotting/propertiesdialog.py", line 45, in on_ok
    self.canvas.draw()
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_qt5agg.py", line 127, in draw
    super(FigureCanvasQTAggBase, self).draw()
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", line 430, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1299, in draw
    renderer, self, artists, self.suppressComposite)
  File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 2437, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/opt/Mantid/lib/mantid/plots/resampling_image/samplingimage.py", line 72, in draw
    self._resample_image()
  File "/opt/Mantid/lib/mantid/plots/resampling_image/samplingimage.py", line 107, in _resample_image
    xbins, ybins = self._calculate_bins_from_extent()
  File "/opt/Mantid/lib/mantid/plots/resampling_image/samplingimage.py", line 98, in _calculate_bins_from_extent
    xbins = int(np.ceil(bbox.width * dpi))
ValueError: cannot convert float NaN to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/Mantid/lib/workbench/plotting/propertiesdialog.py", line 49, in on_ok
    self.canvas.draw()
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_qt5agg.py", line 127, in draw
    super(FigureCanvasQTAggBase, self).draw()
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", line 430, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1299, in draw
    renderer, self, artists, self.suppressComposite)
  File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 2437, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/opt/Mantid/lib/mantid/plots/resampling_image/samplingimage.py", line 72, in draw
    self._resample_image()
  File "/opt/Mantid/lib/mantid/plots/resampling_image/samplingimage.py", line 107, in _resample_image
    xbins, ybins = self._calculate_bins_from_extent()
  File "/opt/Mantid/lib/mantid/plots/resampling_image/samplingimage.py", line 98, in _calculate_bins_from_extent
    xbins = int(np.ceil(bbox.width * dpi))
ValueError: cannot convert float NaN to integer

To Reproduce

  1. Load SANSLOQCan2D.xs from the training course data, but set SpectrumMin = 1 and SpectrumMax = 20
  2. Right click and select "Plot>Colorfill"
  3. Double click a value on the y-axis to open the "Edit axis" dialog.
  4. Select the "Log" checkbox and click OK.

Expected behavior Either disable the log button or display a message when attempting to apply the option.

Platform/Version (please complete the following information):

  • OS: Ubunutu
  • OS Version: 18.04
  • Confirmed in 6.2 and 6.3

thomashampson avatar Feb 08 '22 11:02 thomashampson

This issue has been automatically marked as stale because it has not had activity in 6 months. It will be closed in 7 days if no further activity occurs. Allowing issues to close as stale helps us filter out issues which can wait for future development time. All issues closed by stale bot act like normal issues; they can be searched for, commented on or reopened at any point. If you'd like a closed stale issue to be considered, feel free to either re-open the issue directly or contact a developer. To extend the lifetime of an issue please comment below, it helps us see that this is still affecting you and you want it fixed in the near-future. Extending the lifetime of an issue may cause the development team to prioritise it over other issues, which may be closed as stale instead.

stale[bot] avatar Aug 10 '22 01:08 stale[bot]

This no longer causes an exception, maybe matplotlib handles it better now.

thomashampson avatar Nov 01 '22 16:11 thomashampson