# Buggy code
def estimate_parameters(self, signal, x1, x2, only_current=False):
    """Estimate the parameters by the two area method

    Parameters
    ----------
    signal : Signal instance
    x1 : float
        Defines the left limit of the spectral range to use for the
        estimation.
    x2 : float
        Defines the right limit of the spectral range to use for the
        estimation.

    only_current : bool
        If False estimates the parameters for the full dataset.

    Returns
    -------
    bool

    """
    axis = signal.axes_manager.signal_axes[0]
    binned = signal.metadata.Signal.binned
    i1, i2 = axis.value_range_to_indices(x1, x2)
    if only_current is True:
        estimation = np.polyfit(
            axis.axis[i1:i2], signal()[i1:i2], self.get_polynomial_order()
        )
        if binned is True:
            self.coefficients.value = estimation / axis.scale
        else:
            self.coefficients.value = estimation
        return True
    else:
        if self.coefficients.map is None:
            self._create_arrays()
        nav_shape = signal.axes_manager._navigation_shape_in_array
        signal.unfold()
        dc = signal.data
        # For polyfit the spectrum goes in the first axis
        if axis.index_in_array > 0:
            dc = np.rollaxis(dc, axis.index_in_array, 0)
        cmaps = np.polyfit(
            axis.axis[i1:i2], dc[i1:i2, :], self.get_polynomial_order()
        ).reshape(
            [
                self.get_polynomial_order() + 1,
            ]
            + nav_shape
        )
        self.coefficients.map["values"][:] = np.rollaxis(cmaps, 0, axis.index_in_array)
        if binned is True:
            self.coefficients.map["values"] /= axis.scale
        self.coefficients.map["is_set"][:] = True
        signal.fold()
        self.fetch_stored_values()
        return True


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-7c69fa23a4d3> in <module>()
----> 1 s.remove_background(signal_range=(0,100), background_type='Polynomial')

/media/storage/PhD/software/hyperspy/dev/hyperspy/hyperspy/hyperspy/signal.pyc in remove_background(self, signal_range, background_type, polynomial_order)
    996 
    997             spectra = self._remove_background_cli(
--> 998                 signal_range, background_estimator)
    999             return spectra
   1000 

/media/storage/PhD/software/hyperspy/dev/hyperspy/hyperspy/hyperspy/signal.pyc in _remove_background_cli(self, signal_range, background_estimator)
    942             signal_range[0],
    943             signal_range[1],
--> 944             only_current=False)
    945         return self - model.as_signal()
    946 

/media/storage/PhD/software/hyperspy/dev/hyperspy/hyperspy/hyperspy/_components/polynomial.py in estimate_parameters(self, signal, x1, x2, only_current)
    112             cmaps = np.polyfit(axis.axis[i1:i2],
    113                                dc[i1:i2, :], self.get_polynomial_order()).reshape([
--> 114                 self.get_polynomial_order() + 1, ] + nav_shape)
    115             self.coefficients.map['values'][:] = np.rollaxis(cmaps, 0,
    116                                                              axis.index_in_array)

TypeError: can only concatenate list (not "tuple") to list

# Fixed code
def estimate_parameters(self, signal, x1, x2, only_current=False):
    """Estimate the parameters by the two area method

    Parameters
    ----------
    signal : Signal instance
    x1 : float
        Defines the left limit of the spectral range to use for the
        estimation.
    x2 : float
        Defines the right limit of the spectral range to use for the
        estimation.

    only_current : bool
        If False estimates the parameters for the full dataset.

    Returns
    -------
    bool

    """
    axis = signal.axes_manager.signal_axes[0]
    binned = signal.metadata.Signal.binned
    i1, i2 = axis.value_range_to_indices(x1, x2)
    if only_current is True:
        estimation = np.polyfit(
            axis.axis[i1:i2], signal()[i1:i2], self.get_polynomial_order()
        )
        if binned is True:
            self.coefficients.value = estimation / axis.scale
        else:
            self.coefficients.value = estimation
        return True
    else:
        if self.coefficients.map is None:
            self._create_arrays()
        nav_shape = signal.axes_manager._navigation_shape_in_array
        unfolded = signal.unfold()
        try:
            dc = signal.data
            # For polyfit the spectrum goes in the first axis
            if axis.index_in_array > 0:
                dc = np.rollaxis(dc, 1, 0)  # Unfolded, so use 1
            cmaps = np.polyfit(
                axis.axis[i1:i2], dc[i1:i2, :], self.get_polynomial_order()
            )
            if axis.index_in_array > 0:
                cmaps = np.rollaxis(cmaps, 0, 2)
            cmap_shape = nav_shape + (self.get_polynomial_order() + 1,)
            self.coefficients.map["values"][:] = cmaps.reshape(cmap_shape)
            if binned is True:
                self.coefficients.map["values"] /= axis.scale
            self.coefficients.map["is_set"][:] = True
        finally:
            if unfolded:
                signal.fold()
        self.fetch_stored_values()
        return True