Skip to content

Commit

Permalink
Merge pull request #2918 from LMSC-NTappy/fix_spikes_removal_tool
Browse files Browse the repository at this point in the history
Fixed spikes_removal_tool bug when no navigator is present
  • Loading branch information
ericpre committed Apr 2, 2022
2 parents 4d15a15 + d749284 commit a03e42a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hyperspy/signal_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1807,8 +1807,9 @@ def find(self, back=False):
minimum),
self.signal.axes_manager.signal_axes[0].index2value(
maximum))
self.signal._plot.pointer._set_indices(
self.coordinates[self.index])
if self.signal._plot.navigator_plot is not None:
self.signal._plot.pointer._set_indices(
self.coordinates[self.index])
self.update_plot()
self.create_interpolation_line()

Expand Down
18 changes: 18 additions & 0 deletions hyperspy/tests/signals/test_spike_removal_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ def test_spikes_removal_tool():
]


def test_spikes_removal_tool_navigation_dimension_0():
#Artificial Signal
s = Signal1D(np.ones(1234))
#Add a spike
s.data[333] = 666

assert s.axes_manager.navigation_dimension == 0

sr = SpikesRemovalInteractive(s)
sr.threshold = 1.5
sr.add_noise = False
sr.find()

sr.apply()

np.testing.assert_allclose(s.data[333], 1, atol=1e-4)


@pytest.mark.parametrize(("add_noise, decimal"), [(True, 1), (False, 5)])
def test_spikes_removal_tool_non_interactive(add_noise, decimal):
s = Signal1D(np.ones((2, 3, 30)))
Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/2918.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug when the spikes_removal_tool would not work interactively for signal with 0-dimension navigation space.

0 comments on commit a03e42a

Please sign in to comment.