Ignore:
Timestamp:
Oct 25, 2017 4:12:46 AM (7 years ago)
Author:
Adam Washington <adam.washington@…>
Children:
be6f7af
Parents:
ff8cb73
Message:

Remove all flake8 complaints

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Corfunc/CorfuncPerspective.py

    rff8cb73 r7be7136  
    11# global 
    2 import sys 
    32from PyQt4 import QtCore 
    43from PyQt4 import QtGui 
    5 from PyQt4 import QtWebKit 
    6  
    7 from twisted.internet import threads 
    8 from twisted.internet import reactor 
    94 
    105# sas-global 
    11 from sas.qtgui.Plotting.PlotterData import Data1D 
    126import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    137from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator 
     
    1812from CorfuncUtils import WIDGETS as W 
    1913 
    20 from matplotlib.backends import qt_compat 
    21 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
     14from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg \ 
     15    as FigureCanvas 
    2216from matplotlib.figure import Figure 
    2317 
     
    2519class MyMplCanvas(FigureCanvas): 
    2620    """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).""" 
    27     def __init__(self, model, parent=None, width=5, height=4, dpi=100): 
     21    def __init__(self, model, width=5, height=4, dpi=100): 
    2822        self.model = model 
    2923        self.fig = Figure(figsize=(width, height), dpi=dpi) 
     
    3125 
    3226        FigureCanvas.__init__(self, self.fig) 
    33         # self.reparent(parent, QPoint(0, 0)) 
    34  
    35         # FigureCanvas.setSizePolicy(self, 
    36         #                            QSizePolicy.Expanding, 
    37         #                            QSizePolicy.Expanding) 
    38         # FigureCanvas.updateGeometry(self) 
    3927 
    4028        self.data = None 
    4129        self.extrap = None 
    4230 
    43     def drawQSpace(self): 
     31    def draw_q_space(self): 
    4432        self.fig.clf() 
    45  
    46         self.qmin = None 
    47         self.qmax1 = None 
    48         self.qmax2 = None 
    4933 
    5034        self.axes = self.fig.add_subplot(111) 
     
    6145            self.axes.axvline(qmax1) 
    6246            self.axes.axvline(qmax2) 
    63             self.axes.set_xlim(min(self.data.x), max(self.data.x)*1.5-0.5*min(self.data.x)) 
     47            self.axes.set_xlim(min(self.data.x), max(self.data.x) * 1.5 - 
     48                               0.5 * min(self.data.x)) 
    6449        if self.extrap: 
    6550            self.axes.plot(self.extrap.x, self.extrap.y) 
     
    7762            self.axes.plot(self.data.x, self.data.y, label="1D Correlation") 
    7863            self.axes.plot(self.data3.x, self.data3.y, label="3D Correlation") 
    79             self.axes.plot(self.data_idf.x, self.data_idf.y, label="Interface Distribution Function") 
     64            self.axes.plot(self.data_idf.x, self.data_idf.y, 
     65                           label="Interface Distribution Function") 
    8066            self.axes.set_xlim(min(self.data.x), max(self.data.x) / 4) 
    8167            self.axes.legend() 
    8268 
    8369        self.draw() 
    84  
    85  
    86     # def sizeHint(self): 
    87     #     w, h = self.get_width_height() 
    88     #     return QSize(w, h) 
    89  
    90     # def minimumSizeHint(self): 
    91     #     return QSize(10, 10) 
    9270 
    9371 
     
    9573    # The controller which is responsible for managing signal slots connections 
    9674    # for the gui and providing an interface to the data model. 
    97     name = "Corfunc" # For displaying in the combo box 
    98     #def __init__(self, manager=None, parent=None): 
     75    name = "Corfunc"  # For displaying in the combo box 
     76 
    9977    def __init__(self, parent=None): 
    10078        super(CorfuncWindow, self).__init__() 
     
    10785        self._calculator = CorfuncCalculator() 
    10886 
    109         self._canvas = MyMplCanvas(self.model, self) 
    110         self._realplot = MyMplCanvas(self.model, self) 
     87        self._canvas = MyMplCanvas(self.model) 
     88        self._realplot = MyMplCanvas(self.model) 
    11189        self.verticalLayout_7.insertWidget(0, self._canvas) 
    11290        self.verticalLayout_7.insertWidget(1, self._realplot) 
     
    11492        # Connect buttons to slots. 
    11593        # Needs to be done early so default values propagate properly. 
    116         self.setupSlots() 
     94        self.setup_slots() 
    11795 
    11896        # Set up the model. 
    119         self.setupModel() 
     97        self.setup_model() 
    12098 
    12199        # Set up the mapper 
    122         self.setupMapper() 
    123  
    124     def setupSlots(self): 
     100        self.setup_mapper() 
     101 
     102    def setup_slots(self): 
    125103        self.extrapolateBtn.clicked.connect(self.extrapolate) 
    126104        self.transformBtn.clicked.connect(self.transform) 
     
    130108        self.model.itemChanged.connect(self.modelChanged) 
    131109 
    132     def setupModel(self): 
     110    def setup_model(self): 
    133111        self.model.setItem(W.W_QMIN, 
    134112                           QtGui.QStandardItem("0.01")) 
     
    158136    def modelChanged(self, item): 
    159137        self.mapper.toFirst() 
    160         self._canvas.drawQSpace() 
     138        self._canvas.draw_q_space() 
    161139 
    162140    def _update_calculator(self): 
     
    165143        qmax2 = float(self.model.item(W.W_QCUTOFF).text()) 
    166144        self._calculator.upperq = (qmax1, qmax2) 
    167         self._calculator.background = float(self.model.item(W.W_BACKGROUND).text()) 
     145        self._calculator.background = \ 
     146            float(self.model.item(W.W_BACKGROUND).text()) 
    168147 
    169148    def extrapolate(self): 
    170149        self._update_calculator() 
    171         params, extrapolation = self._calculator.compute_extrapolation() 
     150        params, extrapolation, _ = self._calculator.compute_extrapolation() 
    172151 
    173152        self.model.setItem(W.W_GUINIERA, QtGui.QStandardItem(str(params['A']))) 
    174153        self.model.setItem(W.W_GUINIERB, QtGui.QStandardItem(str(params['B']))) 
    175154        self.model.setItem(W.W_PORODK, QtGui.QStandardItem(str(params['K']))) 
    176         self.model.setItem(W.W_PORODSIGMA, QtGui.QStandardItem(str(params['sigma']))) 
     155        self.model.setItem(W.W_PORODSIGMA, 
     156                           QtGui.QStandardItem(str(params['sigma']))) 
    177157 
    178158        self._canvas.extrap = extrapolation 
    179         self._canvas.drawQSpace() 
    180  
     159        self._canvas.draw_q_space() 
    181160 
    182161    def transform(self): 
     
    188167        extrap = self._canvas.extrap 
    189168        bg = float(self.model.item(W.W_BACKGROUND).text()) 
     169 
    190170        def updatefn(*args, **kwargs): 
    191171            pass 
     
    212192 
    213193        self._update_calculator() 
    214         self._calculator.compute_transform(extrap, method, bg, completefn, updatefn) 
    215  
    216  
    217     def setupMapper(self): 
     194        self._calculator.compute_transform(extrap, method, bg, 
     195                                           completefn, updatefn) 
     196 
     197    def setup_mapper(self): 
    218198        self.mapper = QtGui.QDataWidgetMapper(self) 
    219199        self.mapper.setOrientation(QtCore.Qt.Vertical) 
     
    269249 
    270250        self._canvas.data = data 
    271         self._canvas.drawQSpace() 
     251        self._canvas.draw_q_space() 
    272252 
    273253        # self.model.item(WIDGETS.W_FILENAME).setData(QtCoreQVariant(self._model_item.text())) 
     
    280260 
    281261        self._allow_close = value 
    282  
    283  
    284 if __name__ == "__main__": 
    285     app = QtGui.QApplication([]) 
    286     import qt4reactor 
    287     # qt4reactor.install() 
    288     # DO NOT move the following import to the top! 
    289     # (unless you know what you're doing) 
    290     from twisted.internet import reactor 
    291     dlg = CorfuncWindow(reactor) 
    292     print(dlg) 
    293     dlg.show() 
    294     # print(reactor) 
    295     # reactor.run() 
    296     sys.exit(app.exec_()) 
Note: See TracChangeset for help on using the changeset viewer.