Skip to content

Commit 401754d

Browse files
committed
Use super() to call parent class method.
We are now dependent on Python 3.5 so we can rely on super() without having to specify self's own type which lends to subtle bugs in case of typos. Also, use super() instead of ParentClass.method() as was the case of DummyDSP and DummySLM.
1 parent f1ef9cd commit 401754d

File tree

12 files changed

+29
-29
lines changed

12 files changed

+29
-29
lines changed

microscope/cameras/andorsdk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class AndorSDK3(devices.FloatingDeviceMixin,
181181
devices.CameraDevice):
182182
SDK_INITIALIZED = False
183183
def __init__(self, index=0, **kwargs):
184-
super(AndorSDK3, self).__init__(index=index, **kwargs)
184+
super().__init__(index=index, **kwargs)
185185
if not AndorSDK3.SDK_INITIALIZED:
186186
SDK3.InitialiseLibrary()
187187
self.handle = None

microscope/cameras/pvcam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ class PVCamera(devices.FloatingDeviceMixin, devices.CameraDevice):
11861186

11871187

11881188
def __init__(self, index=0, **kwargs):
1189-
super(PVCamera, self).__init__(index=index, **kwargs)
1189+
super().__init__(index=index, **kwargs)
11901190
# Camera name in DLL.
11911191
self._pv_name = None
11921192
# Camera handle.

microscope/cameras/ximea.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
@Pyro4.behavior('single')
5454
class XimeaCamera(devices.CameraDevice):
5555
def __init__(self, **kwargs):
56-
super(XimeaCamera, self).__init__(**kwargs)
56+
super().__init__(**kwargs)
5757
self._acquiring = False
5858
self._exposure_time = 0.1
5959
self._triggered = False

microscope/clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _connect(self):
5959
class DataClient(Client):
6060
"""A client that can receive and buffer data."""
6161
def __init__(self, url):
62-
super(DataClient, self).__init__(url)
62+
super().__init__(url)
6363
self._buffer = queue.Queue()
6464
# Register self with a listener.
6565
if self._url.split('@')[1].split(':')[0] in ['127.0.0.1', 'localhost']:

microscope/devices.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class DataDevice(Device):
394394

395395
def __init__(self, buffer_length=0, **kwargs):
396396
"""Derived.__init__ must call this at some point."""
397-
super(DataDevice, self).__init__(**kwargs)
397+
super().__init__(**kwargs)
398398
# A thread to fetch and dispatch data.
399399
self._fetch_thread = None
400400
# A flag to control the _fetch_thread.
@@ -469,7 +469,7 @@ def disable(self):
469469
if self._fetch_thread.is_alive():
470470
self._fetch_thread_run = False
471471
self._fetch_thread.join()
472-
super(DataDevice, self).disable()
472+
super().disable()
473473

474474
@abc.abstractmethod
475475
def _fetch_data(self):
@@ -599,7 +599,7 @@ def set_client(self, new_client):
599599
@keep_acquiring
600600
def update_settings(self, settings, init=False):
601601
"""Update settings, toggling acquisition if necessary."""
602-
super(DataDevice, self).update_settings(settings, init)
602+
super().update_settings(settings, init)
603603

604604
# noinspection PyPep8Naming
605605
def receiveClient(self, client_uri):
@@ -641,7 +641,7 @@ class CameraDevice(DataDevice):
641641
ALLOWED_TRANSFORMS = [p for p in itertools.product(*3 * [[False, True]])]
642642

643643
def __init__(self, **kwargs):
644-
super(CameraDevice, self).__init__(**kwargs)
644+
super().__init__(**kwargs)
645645
# A list of readout mode descriptions.
646646
self._readout_modes = ['default']
647647
# The index of the current readout mode.
@@ -880,7 +880,7 @@ class SerialDeviceMixIn:
880880
__metaclass__ = abc.ABCMeta
881881

882882
def __init__(self, **kwargs):
883-
super(SerialDeviceMixIn, self).__init__(**kwargs)
883+
super().__init__(**kwargs)
884884
## TODO: We should probably construct the connection here but
885885
## the Serial constructor takes a lot of arguments, and
886886
## it becomes tricky to separate those from arguments to
@@ -959,7 +959,7 @@ def __init__(self, **kwargs) -> None:
959959
`_pattern_idx` are initialized to None to support the queueing
960960
of patterns and software triggering.
961961
"""
962-
super(DeformableMirror, self).__init__(**kwargs)
962+
super().__init__(**kwargs)
963963

964964
self._patterns = None # type: typing.Optional[numpy.ndarray]
965965
self._pattern_idx = -1 # type: int
@@ -1030,7 +1030,7 @@ class LaserDevice(Device):
10301030

10311031
@abc.abstractmethod
10321032
def __init__(self, **kwargs):
1033-
super(LaserDevice, self).__init__(**kwargs)
1033+
super().__init__(**kwargs)
10341034
self._set_point = None
10351035

10361036
@abc.abstractmethod
@@ -1090,7 +1090,7 @@ class FilterWheelBase(Device):
10901090
__metaclass__ = abc.ABCMeta
10911091

10921092
def __init__(self, filters=[], positions=0, **kwargs):
1093-
super(FilterWheelBase, self).__init__(**kwargs)
1093+
super().__init__(**kwargs)
10941094
if isinstance(filters, dict):
10951095
self._filters = filters
10961096
else:

microscope/deviceserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __init__(self, device_def, id_to_host, id_to_port, exit_event=None):
110110
self._id_to_port = id_to_port
111111
# A shared event to allow clean shutdown.
112112
self.exit_event = exit_event
113-
super(DeviceServer, self).__init__()
113+
super().__init__()
114114
self.daemon = True
115115

116116
def clone(self):

microscope/lasers/cobolt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
class CoboltLaser(devices.SerialDeviceMixIn, devices.LaserDevice):
2727
def __init__(self, com=None, baud=115200, timeout=0.01, **kwargs):
28-
super(CoboltLaser, self).__init__(**kwargs)
28+
super().__init__(**kwargs)
2929
self.connection = serial.Serial(port = com,
3030
baudrate = baud, timeout = timeout,
3131
stopbits = serial.STOPBITS_ONE,

microscope/lasers/deepstar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
class DeepstarLaser(devices.SerialDeviceMixIn, devices.LaserDevice):
2727
def __init__(self, com, baud=9600, timeout=2.0, **kwargs):
28-
super(DeepstarLaser, self).__init__(**kwargs)
28+
super().__init__(**kwargs)
2929
self.connection = serial.Serial(port = com,
3030
baudrate = baud, timeout = timeout,
3131
stopbits = serial.STOPBITS_ONE,

microscope/lasers/sapphire.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, com=None, baud=19200, timeout=0.5, **kwargs):
3939
# laser controller must run at 19200 baud, 8+1 bits,
4040
# no parity or flow control
4141
# timeout is recomended to be over 0.5
42-
super(SapphireLaser, self).__init__(**kwargs)
42+
super().__init__(**kwargs)
4343
self.connection = serial.Serial(port = com,
4444
baudrate = baud, timeout = timeout,
4545
stopbits = serial.STOPBITS_ONE,
@@ -57,7 +57,7 @@ def __init__(self, com=None, baud=19200, timeout=0.5, **kwargs):
5757
self._logger.info("Sapphire laser serial number: [%s]" % headID)
5858

5959
def _write(self, command):
60-
count = super(SapphireLaser, self)._write(command)
60+
count = super()._write(command)
6161
## This device always writes backs something. If echo is on,
6262
## it's the whole command, otherwise just an empty line. Read
6363
## it and throw it away.

microscope/mirror/alpao.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(self, serial_number, **kwargs):
102102
serial_number: string
103103
The serial number of the deformable mirror, something like "BIL103".
104104
"""
105-
super(AlpaoDeformableMirror, self).__init__(**kwargs)
105+
super().__init__(**kwargs)
106106

107107
## We need to constantly check for errors and need a buffer to
108108
## have the message written to. To avoid creating a new buffer
@@ -152,7 +152,7 @@ def set_trigger(self, ttype, tmode):
152152

153153
def queue_patterns(self, patterns):
154154
if self._trigger_type == TriggerType.SOFTWARE:
155-
super(AlpaoDeformableMirror, self).queue_patterns(patterns)
155+
super().queue_patterns(patterns)
156156
return
157157

158158
self._validate_patterns(patterns)
@@ -182,7 +182,7 @@ def queue_patterns(self, patterns):
182182

183183
def next_pattern(self):
184184
if self.trigger_type == TriggerType.SOFTWARE:
185-
super(AlpaoDeformableMirror, self).next_pattern()
185+
super().next_pattern()
186186
else:
187187
raise Exception("software trigger received when set for"
188188
" hardware trigger")
@@ -192,4 +192,4 @@ def __del__(self):
192192
if status != asdk.SUCCESS:
193193
msg = self._find_error_str()
194194
warnings.warn(msg)
195-
super(AlpaoDeformableMirror, self).__del__()
195+
super().__del__()

0 commit comments

Comments
 (0)