From 97344c9f21f7111fe813ec32a51c8bd806fcdf53 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Thu, 30 Oct 2014 13:38:03 +0100 Subject: [PATCH] cleaned up object type class definition for FilterOptions, programs now only use methods to access attributes --- pylot/core/read/inputs.py | 41 +++++++++++++++++--------------------- pylot/core/util/widgets.py | 14 +++++++++---- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/pylot/core/read/inputs.py b/pylot/core/read/inputs.py index a33068cd..ee840b8f 100644 --- a/pylot/core/read/inputs.py +++ b/pylot/core/read/inputs.py @@ -165,39 +165,34 @@ class FilterOptions(object): ''' def __init__(self, filtertype='bandpass', freq=[2., 5.], order=3, **kwargs): - self.__filterInformation = {} - self._setFilterType(filtertype) - self._setFreq(freq) - self._setOrder(order) + self.setFilterType(filtertype) + self.setFreq(freq) + self.setOrder(order) def __str__(self): hrs = '''\n\tFilter parameter:\n Type:\t\t{ftype}\n Frequencies:\t{freq}\n Order:\t\t{order}\n - '''.format(ftype=self.filterType, - freq=self.freq, - order=self.order) + '''.format(ftype=self.getFilterType(), + freq=self.getFreq(), + order=self.getOrder()) return hrs - def _getFreq(self): - return self.__filterInformation['freq'] + def getFreq(self): + return self.freq - def _setFreq(self, freq): - self.__filterInformation['freq'] = freq + def setFreq(self, freq): + self.freq = freq - def _getOrder(self): - return self.__filterInformation['order'] + def getOrder(self): + return self.order - def _setOrder(self, order): - self.__filterInformation['order'] = order + def setOrder(self, order): + self.order = order - def _getFilterType(self): - return self.__filterInformation['filtertype'] + def getFilterType(self): + return self.filterType - def _setFilterType(self, filtertype): - self.__filterInformation['filtertype'] = filtertype - - filterType = property(fget=_getFilterType, fset=_setFilterType) - order = property(fget=_getOrder, fset=_setOrder) - freq = property(fget=_getFreq, fset=_setFreq) + def setFilterType(self, filtertype): + self.filterType = filtertype diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 20ebc95c..a0476cd0 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -157,8 +157,11 @@ class FilterOptionsDialog(QDialog): adjust parameters for filtering seismic data. """ super(FilterOptionsDialog, self).__init__() - - self.filterOptions = [filterOptions if filterOptions is not None else FilterOptions()][0] + + if filterOptions is not None: + self.filterOptions = filterOptions + else: + self.filterOptions = FilterOptions() self.freqminLabel = QLabel() self.freqminLabel.setText("minimum:") @@ -166,7 +169,7 @@ class FilterOptionsDialog(QDialog): self.freqminSpinBox.setRange(5e-7, 1e6) self.freqminSpinBox.setDecimals(2) self.freqminSpinBox.setSuffix(' Hz') - self.freqminSpinBox.setValue(filterOptions.freq[0]) + self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0]) self.freqmaxLabel = QLabel() self.freqmaxLabel.setText("maximum:") self.freqmaxSpinBox = QDoubleSpinBox() @@ -174,7 +177,7 @@ class FilterOptionsDialog(QDialog): self.freqmaxSpinBox.setDecimals(2) self.freqmaxSpinBox.setSuffix(' Hz') if self.filterOptions.filterType in ['bandpass', 'bandstop']: - self.freqmaxSpinBox.setValue(self.filterOptions.freq[1]) + self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1]) typeOptions = ["bandpass", "bandstop", "lowpass", "highpass"] @@ -243,6 +246,9 @@ class FilterOptionsDialog(QDialog): self.filterOptions.freq = freq self.filterOptions.order = self.orderSpinBox.value() return self.filterOptions + + def getFilterOptions(self): + return self.filterOptions class LoadDataDlg(QDialog):