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

Fix bug with side by side plotting of signal containing navigation dimension only #3304

Conversation

ericpre
Copy link
Member

@ericpre ericpre commented Feb 2, 2024

Progress of the PR

  • Fix bug described in title,
  • [n/a] update docstring (if appropriate),
  • [n/a] update user guide (if appropriate),
  • add an changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • Check formatting changelog entry in the readthedocs doc build of this PR (link in github checks)
  • add tests,
  • ready for review.

Minimal example of the bug fix or the new feature

import hyperspy.api as hs
import matplotlib
import numpy as np

matplotlib.use("module://ipympl.backend_nbagg")
s = hs.signals.Signal2D(np.random.random((2, 2))).T
s.plot()

Give the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], line 2
      1 s = hs.signals.Signal2D(np.random.random((2, 2))).T
----> 2 s.plot()

File ~\Dev\hyperspy\hyperspy\signal.py:2954, in BaseSignal.plot(self, navigator, axes_manager, plot_markers, **kwargs)
   2949     else:
   2950         raise ValueError(
   2951             'navigator must be one of "spectrum","auto", '
   2952             '"slider", None, a Signal instance')
-> 2954 self._plot.plot(**kwargs)
   2955 self.events.data_changed.connect(self.update_plot, [])
   2957 p = self._plot.signal_plot if self._plot.signal_plot else self._plot.navigator_plot

File ~\Dev\hyperspy\hyperspy\drawing\mpl_he.py:220, in MPL_HyperExplorer.plot(self, **kwargs)
    218     import matplotlib.pyplot as plt
    219     with plt.ioff():
--> 220         plot_sig_and_nav(plot_style)
    221 else:
    222     plot_sig_and_nav(plot_style)

File ~\Dev\hyperspy\hyperspy\drawing\mpl_he.py:214, in MPL_HyperExplorer.plot.<locals>.plot_sig_and_nav(plot_style)
    212     display(self.signal_plot.figure.canvas)
    213 elif plot_style == "horizontal":
--> 214     display(HBox([self.navigator_plot.figure.canvas,self.signal_plot.figure.canvas]))
    215 else: # plot_style == "vertical":
    216     display(VBox([self.navigator_plot.figure.canvas, self.signal_plot.figure.canvas]))

AttributeError: 'NoneType' object has no attribute 'figure'

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b104055) 80.23% compared to head (3dd0912) 80.33%.

Additional details and impacted files
@@                  Coverage Diff                   @@
##           RELEASE_next_patch    #3304      +/-   ##
======================================================
+ Coverage               80.23%   80.33%   +0.10%     
======================================================
  Files                     147      147              
  Lines                   21846    21848       +2     
  Branches                 5140     5141       +1     
======================================================
+ Hits                    17528    17552      +24     
+ Misses                   3112     3083      -29     
- Partials                 1206     1213       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jlaehne jlaehne merged commit f303777 into hyperspy:RELEASE_next_patch Feb 3, 2024
25 of 28 checks passed
@ericpre ericpre deleted the fix_side_by_side_plot_navigation_only branch February 3, 2024 19:45
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.

None yet

2 participants