1616
1717
1818import numpy as np
19- import sys
2019
2120class AD9959DDSSweeper (IntermediateDevice ):
2221 allowed_children = [DDS , StaticDDS ]
@@ -169,9 +168,9 @@ def quantise_freq(self, data, device):
169168 data = np .array (data )
170169 # Ensure that frequencies are within bounds:
171170 if np .any (data > self .dds_clock / 2. ) or np .any (data < 0.0 ):
172- raise LabscriptError ('%s %s ' % ( device .description , device .name ) +
173- 'can only have frequencies between 0.0Hz and %f MHz, ' +
174- 'the limit imposed by %s.' % ( self .name , self . dds_clock / 2e6 ) )
171+ raise LabscriptError (f' { device .description :s } { device .name :s } ' +
172+ f 'can only have frequencies between 0.0Hz and { self . dds_clock / 2e6 :.1f } MHz, ' +
173+ f 'the limit imposed by { self .name :s } .' )
175174
176175 # It's faster to add 0.5 then typecast than to round to integers first:
177176 data = np .array ((self .freq_scale * data )+ 0.5 ,dtype = '<u4' )
@@ -224,10 +223,10 @@ def generate_code(self, hdf5_file):
224223 Please decrease the sample rates of devices on the same clock, \
225224 or connect { self .name } to a different pseudoclock.' )
226225 try :
227- prefix , channel = output .connection .split ()
226+ _ , channel = output .connection .split ()
228227 channel = int (channel )
229228 assert channel in range (4 ), 'requested channel out of range'
230- except :
229+ except Exception :
231230 raise LabscriptError ('%s %s has invalid connection string: \' %s\' . ' % (output .description ,output .name ,str (output .connection )) +
232231 'Format must be \' channel n\' with n from 0 to 4.' )
233232
@@ -250,6 +249,7 @@ def generate_code(self, hdf5_file):
250249 dyn_dtypes = {'names' :['%s%d' % (k , i ) for i in dyn_DDSs for k in ['freq' , 'amp' , 'phase' ] ],
251250 'formats' :[f for i in dyn_DDSs for f in ('<u4' , '<u2' , '<u2' )]}
252251
252+ # TODO: may not be necessary, should be able to get length from dds.xxxx.raw_output size
253253 clockline = self .parent_clock_line
254254 pseudoclock = clockline .parent_device
255255 times = pseudoclock .times [clockline ]
@@ -268,7 +268,7 @@ def generate_code(self, hdf5_file):
268268
269269 static_table = np .zeros (1 , dtype = static_dtypes )
270270
271- for connection in list ( stat_DDSs .keys () ):
271+ for connection in stat_DDSs .keys ():
272272 sdds = stat_DDSs [connection ]
273273 static_table ['freq%d' % connection ] = sdds .frequency .raw_output [0 ]
274274 static_table ['amp%d' % connection ] = sdds .amplitude .raw_output [0 ]
0 commit comments