Skip to content

Commit

Permalink
Fix model tests
Browse files Browse the repository at this point in the history
  • Loading branch information
francisco-dlp committed Oct 9, 2023
1 parent 96aa133 commit 3d5896d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hyperspy/tests/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def setup_method(self, method):
m[0].centre.value = 2.0
m[0].sigma.twin = m[0].centre
m._convolve_signal = mock.MagicMock()
m.convolve_signal.return_value = self.convolve_signal
m._convolve_signal._get_current_data = mock.MagicMock()
m._convolve_signal._get_current_data.return_value = self.convolve_signal

self.model = m
m.convolution_axis = np.zeros(2)

Expand Down Expand Up @@ -111,7 +113,8 @@ def test_call_method_no_convolutions(self):
def test_call_method_with_convolutions(self):
m = self.model
m._convolve_signal = mock.MagicMock()
m.convolve_signal.return_value = 0.3
m._convolve_signal._get_current_data = mock.MagicMock()
m._convolve_signal._get_current_data.return_value = 0.3
m.convolved = True

m.append(hs.model.components1D.Gaussian())
Expand Down Expand Up @@ -155,15 +158,15 @@ def test_model2plot_own_am(self):
res, np.array([np.nan, 0.5, 0.25, np.nan, np.nan])
)
assert m.__call__.called
assert m._call__.call_args[1] == {"non_convolved": False, "onlyactive": True}
assert m.__call__.call_args[1] == {"non_convolved": False, "onlyactive": True}
assert not m.fetch_stored_values.called

def test_model2plot_other_am(self):
m = self.model
res = m._model2plot(m.axes_manager.deepcopy(), out_of_range2nans=False)
np.testing.assert_array_equal(res, np.array([0.5, 0.25]))
assert m.__call__.called
assert m._call__.call_args[1] == {"non_convolved": False, "onlyactive": True}
assert m.__call__.call_args[1] == {"non_convolved": False, "onlyactive": True}
assert 2 == m.fetch_stored_values.call_count


Expand Down

0 comments on commit 3d5896d

Please sign in to comment.