Skip to content

Commit

Permalink
Merge pull request hyperspy#2654 from ericpre/fix_fit_component_traits
Browse files Browse the repository at this point in the history
Fix warning when using fit component and add iterpath to GUI
  • Loading branch information
francisco-dlp authored Mar 9, 2021
2 parents 7532ed2 + ca7fef7 commit e35f149
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RELEASE_next_patch (Unreleased)
* Added lazy reading support for FFT and DPC datasets in FEI emd datasets (`#2651 <https://github.com/hyperspy/hyperspy/pull/2651>`_).
* Fix various future and deprecation warnings from numpy and scikit-learn (`#2646 <https://github.com/hyperspy/hyperspy/pull/2646>`_)
* Improve error message when initialising SpanROI with left >= right (`#2604 <https://github.com/hyperspy/hyperspy/pull/2604>`_)
* Fix ``iterpath`` VisibleDeprecationWarning when using ``fit_component`` (`#2654 <https://github.com/hyperspy/hyperspy/pull/2654>`_)
* Fix various bugs with `CircleWidget` and `Line2DWidget` (`#2625 <https://github.com/hyperspy/hyperspy/pull/2625>`_)
* Allow running the test suite without the pytest-mpl plugin (`#2624 <https://github.com/hyperspy/hyperspy/pull/2624>`_)
* Fix setting signal range of model with negative axis scales (`#2656 <https://github.com/hyperspy/hyperspy/pull/2656>`_)
Expand Down
9 changes: 7 additions & 2 deletions hyperspy/models/model1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import numpy as np
from scipy.special import huber
import traits.api as t

import hyperspy.drawing.signal1d
from hyperspy.axes import generate_axis
Expand All @@ -35,10 +36,13 @@

@add_gui_method(toolkey="hyperspy.Model1D.fit_component")
class ComponentFit(SpanSelectorInSignal1D):
only_current = t.Bool(True)
iterpath = t.Enum('flyback', 'serpentine', default='serpentine',
desc='Define the iterating pattern over the navigation space.')

def __init__(self, model, component, signal_range=None,
estimate_parameters=True, fit_independent=False,
only_current=True, **kwargs):
only_current=True, iterpath='flyback', **kwargs):
if model.signal.axes_manager.signal_dimension != 1:
raise SignalDimensionError(
model.signal.axes_manager.signal_dimension, 1)
Expand All @@ -53,6 +57,7 @@ def __init__(self, model, component, signal_range=None,
self.fit_independent = fit_independent
self.fit_kwargs = kwargs
self.only_current = only_current
self.iterpath = iterpath
if signal_range == "interactive":
if (not hasattr(self.model, '_plot') or self.model._plot is None or
not self.model._plot.is_active):
Expand Down Expand Up @@ -106,7 +111,7 @@ def _fit_fired(self):
if only_current:
self.model.fit(**self.fit_kwargs)
else:
self.model.multifit(**self.fit_kwargs)
self.model.multifit(iterpath=self.iterpath, **self.fit_kwargs)

# Restore the signal range
if self.signal_range is not None:
Expand Down

0 comments on commit e35f149

Please sign in to comment.