Convert formatting automatically to f-strings

Automatically convert formatting with the following call:
flynt -ll 2000 -v frappy*
Result: 303/381 auto-converted.
Failing conversions will be looked at manually in a follow-up commit.

Change-Id: Icd996b27221202faccc15af78e0380cf52ee37f2
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30900
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
Alexander Zaft
2023-04-14 07:12:03 +02:00
committed by Markus Zolliker
parent a9d479ba0a
commit 6f95c0d825
56 changed files with 327 additions and 380 deletions

View File

@ -117,8 +117,7 @@ class GarfieldMagnet(SequencerMixin, Drivable):
minfield = -maxfield
if not minfield <= field <= maxfield:
raise ValueError(self,
'requested field %g T out of range %g..%g T' %
(field, minfield, maxfield))
f'requested field {field:g} T out of range {minfield:g}..{maxfield:g} T')
while minfield <= field <= maxfield:
# binary search
trycurr = 0.5 * (mincurr + maxcurr)
@ -171,8 +170,7 @@ class GarfieldMagnet(SequencerMixin, Drivable):
amin, amax = self.abslimits
if umin > umax:
raise ValueError(
self, 'user minimum (%s) above the user '
'maximum (%s)' % (umin, umax))
self, f'user minimum ({umin}) above the user maximum ({umax})')
if umin < amin - abs(amin * 1e-12):
umin = amin
if umax > amax + abs(amax * 1e-12):
@ -265,16 +263,13 @@ class GarfieldMagnet(SequencerMixin, Drivable):
cleanup=self._ramp_current_cleanup))
seq.append(
Step(
'set polarity %s' %
wanted_polarity,
f'set polarity {wanted_polarity}',
0.3,
self._set_polarity,
wanted_polarity)) # no cleanup
seq.append(
Step(
'ramping to %.3fT (%.2fA)' %
(target,
wanted_current),
f'ramping to {target:.3f}T ({wanted_current:.2f}A)',
0.3,
self._ramp_current,
wanted_current,