Skip to content

Commit 7dde879

Browse files
committed
made consistent with PEP8
1 parent 8b9b758 commit 7dde879

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

pylearn2/train_extensions/live_monitoring.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
zmq_available = True
1717
except:
1818
zmq_available = False
19-
19+
2020
try:
2121
from PySide import QtCore, QtGui
2222

2323
import sys
2424
import matplotlib
2525
matplotlib.use('Qt4Agg')
26-
matplotlib.rcParams['backend.qt4']='PySide'
26+
matplotlib.rcParams['backend.qt4'] = 'PySide'
2727

28-
from matplotlib.backends.backend_qt4agg \
29-
import FigureCanvasQTAgg as FigureCanvas
28+
from matplotlib.backends.backend_qt4agg import (
29+
FigureCanvasQTAgg as FigureCanvas)
3030
from matplotlib.figure import Figure
3131

3232
qt_available = True
@@ -388,14 +388,13 @@ def follow_channels(self, channel_list):
388388
plt.ion()
389389
plt.draw()
390390

391-
392391
def follow_channels_qt(self, channel_list):
393392
"""
394393
Tracks and plots a specified set of channels in real time using
395394
a PySide Qt GUI. If the plot is closed, it can be reopened by
396395
calling lm.gui.start() (where lm is the instance of LiveMonitor)
397396
or new channels can be specified by calling this method again.
398-
397+
399398
Alternative to the follow_channels method which avoids relying
400399
on matplotlib's interactive mode, which may not work for some
401400
setups.
@@ -408,46 +407,45 @@ def follow_channels_qt(self, channel_list):
408407
if not qt_available:
409408
raise ImportError('PySide needs to be installed for ' +
410409
'this functionality')
411-
410+
412411
# only create qt app if running the first time
413412
if not hasattr(self, 'gui'):
414413
self.gui = LiveMonitorGUI(self, channel_list)
415-
414+
416415
self.gui.channel_list = channel_list
417416
self.gui.start()
418417

419-
420418
if qt_available:
421419
class LiveMonitorGUI(QtGui.QMainWindow):
422420
def __init__(self, lm, channel_list):
423421
"""
424422
PySide GUI implementation for live monitoring channels.
425-
423+
426424
Parameters
427425
----------
428426
lm : LiveMonitor instance
429427
The LiveMonitor instance to which the GUI belongs.
430-
428+
431429
channel_list : list
432430
A list of the channels to display.
433431
"""
434432
self.app = QtGui.QApplication(sys.argv)
435-
433+
436434
super(LiveMonitorGUI, self).__init__()
437435
self.lm = lm
438436
self.channel_list = channel_list
439437
self.initUI()
440-
438+
441439
def initUI(self):
442-
self.fig = Figure(figsize=(600,600), dpi=72, facecolor=(1,1,1),
443-
edgecolor=(0,0,0))
440+
self.fig = Figure(figsize=(600, 600), dpi=72,
441+
facecolor=(1, 1, 1), edgecolor=(0, 0, 0))
444442
self.ax = self.fig.add_subplot(111)
445443
self.canvas = FigureCanvas(self.fig)
446444
self.setCentralWidget(self.canvas)
447-
445+
448446
def update(self):
449447
self.lm.update_channels(self.channel_list)
450-
self.ax.cla() # clear previous plot
448+
self.ax.cla() # clear previous plot
451449
for channel_name in self.channel_list:
452450
self.ax.plot(
453451
self.lm.channels[channel_name].epoch_record,
@@ -456,11 +454,11 @@ def update(self):
456454
)
457455
self.ax.legend()
458456
self.canvas.draw()
459-
457+
460458
def closeEvent(self, event):
461459
self.updateTimer.stop()
462460
event.accept()
463-
461+
464462
def start(self):
465463
self.updateTimer = QtCore.QTimer(self)
466464
self.updateTimer.timeout.connect(self.update)

0 commit comments

Comments
 (0)