Skip to content

Commit efee2ff

Browse files
remove f-strings (#916)
1 parent 3ff3710 commit efee2ff

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

qcodes/utils/magic.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
if sys.version_info < (3, 6):
55
raise RuntimeError('Magic only supported for Python version 3.6 and up')
66

7+
78
@magics_class
89
class QCoDeSMagic(Magics):
910
"""Magics related to code management (loading, saving, editing, ...)."""
@@ -82,11 +83,10 @@ def measurement(self, line, cell=None):
8283
data_name = options.get('d', 'data')
8384
loop_name = options.get('l', 'loop')
8485

85-
8686
lines = cell.splitlines()
8787
assert lines[0][:3] == 'for', "Measurement must start with for loop"
8888

89-
contents = f'import qcodes\n{loop_name} = '
89+
contents = 'import qcodes\n{} = '.format(loop_name)
9090
previous_level = 0
9191
for k, line in enumerate(lines):
9292
line, level = line.lstrip(), int((len(line)-len(line.lstrip())) / 4)
@@ -99,7 +99,7 @@ def measurement(self, line, cell=None):
9999
continue
100100
else:
101101
line_representation = ' ' * level * 4
102-
if level < previous_level :
102+
if level < previous_level:
103103
# Exiting inner loop, close bracket
104104
line_representation += '),' * (previous_level - level)
105105
line_representation += '\n' + ' ' * level * 4
@@ -109,13 +109,16 @@ def measurement(self, line, cell=None):
109109
for_opts, for_code = self.parse_options(line[4:-1], 'd:')
110110
if 'd' in for_opts:
111111
# Delay option provided
112-
line_representation += f'qcodes.Loop({for_code}, ' \
113-
f'delay={for_opts["d"]}).each(\n'
112+
line_representation += ('qcodes.Loop({}, '
113+
'delay={}).each(\n'
114+
''.format(for_code,
115+
for_opts["d"]))
114116
else:
115-
line_representation += f'qcodes.Loop({for_code}).each(\n'
117+
line_representation += ('qcodes.Loop({}).each(\n'
118+
''.format(for_code))
116119
else:
117120
# Action in current loop
118-
line_representation += f'{line},\n'
121+
line_representation += '{},\n'.format(line)
119122
contents += line_representation
120123

121124
# Remember level for next iteration (might exit inner loop)
@@ -124,7 +127,9 @@ def measurement(self, line, cell=None):
124127
# Add closing brackets for any remaining loops
125128
contents += ')' * previous_level + '\n'
126129
# Add dataset
127-
contents += f"{data_name} = {loop_name}.get_data_set(name='{msmt_name}')"
130+
contents += "{} = {}.get_data_set(name='{}')".format(data_name,
131+
loop_name,
132+
msmt_name)
128133

129134
for line in lines[k+1:]:
130135
contents += '\n' + line
@@ -154,6 +159,6 @@ def register_magic_class(cls=QCoDeSMagic, magic_commands=True):
154159
if magic_commands is not True:
155160
# filter out any magic commands that are not in magic_commands
156161
cls.magics = {line_cell: {key: val for key, val in magics.items()
157-
if key in magic_commands}
162+
if key in magic_commands}
158163
for line_cell, magics in cls.magics.items()}
159-
ip.magics_manager.register(cls)
164+
ip.magics_manager.register(cls)

0 commit comments

Comments
 (0)