remove f-strings for python 3.5 compatibility (#854)

This commit is contained in:
pzhokhov
2019-03-16 11:54:47 -07:00
committed by GitHub
parent 1259f6ab25
commit 1b092434fc
4 changed files with 4 additions and 4 deletions

View File

@@ -123,7 +123,7 @@ def mpi_weighted_mean(comm, local_name2valcount):
val = float(val) val = float(val)
except ValueError: except ValueError:
if comm.rank == 0: if comm.rank == 0:
warnings.warn(f'WARNING: tried to compute mean on non-float {name}={val}') warnings.warn('WARNING: tried to compute mean on non-float {}={}'.format(name, val))
else: else:
name2sum[name] += val * count name2sum[name] += val * count
name2count[name] += count name2count[name] += count

View File

@@ -177,7 +177,7 @@ def profile_tf_runningmeanstd():
outfile = '/tmp/timeline.json' outfile = '/tmp/timeline.json'
with open(outfile, 'wt') as f: with open(outfile, 'wt') as f:
f.write(chrome_trace) f.write(chrome_trace)
print(f'Successfully saved profile to {outfile}. Exiting.') print('Successfully saved profile to {}. Exiting.'.format(outfile))
exit(0) exit(0)
''' '''

View File

@@ -17,7 +17,7 @@ def test_mpi_weighted_mean():
d = mpi_util.mpi_weighted_mean(comm, name2valcount) d = mpi_util.mpi_weighted_mean(comm, name2valcount)
correctval = {'a' : (10 * 2 + 19) / 3.0, 'b' : 20, 'c' : 42} correctval = {'a' : (10 * 2 + 19) / 3.0, 'b' : 20, 'c' : 42}
if comm.rank == 0: if comm.rank == 0:
assert d == correctval, f'{d} != {correctval}' assert d == correctval, '{} != {}'.format(d, correctval)
for name, (val, count) in name2valcount.items(): for name, (val, count) in name2valcount.items():
for _ in range(count): for _ in range(count):

View File

@@ -232,7 +232,7 @@ def main(args):
env.render() env.render()
done = done.any() if isinstance(done, np.ndarray) else done done = done.any() if isinstance(done, np.ndarray) else done
if done: if done:
print(f'episode_rew={episode_rew}') print('episode_rew={}'.format(episode_rew))
episode_rew = 0 episode_rew = 0
obs = env.reset() obs = env.reset()