From 1b092434fc51efcb25d6650e287f07634ada1e08 Mon Sep 17 00:00:00 2001 From: pzhokhov Date: Sat, 16 Mar 2019 11:54:47 -0700 Subject: [PATCH] remove f-strings for python 3.5 compatibility (#854) --- baselines/common/mpi_util.py | 2 +- baselines/common/running_mean_std.py | 2 +- baselines/common/test_mpi_util.py | 2 +- baselines/run.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/baselines/common/mpi_util.py b/baselines/common/mpi_util.py index d05d9cf..ca7044e 100644 --- a/baselines/common/mpi_util.py +++ b/baselines/common/mpi_util.py @@ -123,7 +123,7 @@ def mpi_weighted_mean(comm, local_name2valcount): val = float(val) except ValueError: 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: name2sum[name] += val * count name2count[name] += count diff --git a/baselines/common/running_mean_std.py b/baselines/common/running_mean_std.py index 6b42e56..963a57f 100644 --- a/baselines/common/running_mean_std.py +++ b/baselines/common/running_mean_std.py @@ -177,7 +177,7 @@ def profile_tf_runningmeanstd(): outfile = '/tmp/timeline.json' with open(outfile, 'wt') as f: f.write(chrome_trace) - print(f'Successfully saved profile to {outfile}. Exiting.') + print('Successfully saved profile to {}. Exiting.'.format(outfile)) exit(0) ''' diff --git a/baselines/common/test_mpi_util.py b/baselines/common/test_mpi_util.py index dcabf2e..b1146ab 100644 --- a/baselines/common/test_mpi_util.py +++ b/baselines/common/test_mpi_util.py @@ -17,7 +17,7 @@ def test_mpi_weighted_mean(): d = mpi_util.mpi_weighted_mean(comm, name2valcount) correctval = {'a' : (10 * 2 + 19) / 3.0, 'b' : 20, 'c' : 42} if comm.rank == 0: - assert d == correctval, f'{d} != {correctval}' + assert d == correctval, '{} != {}'.format(d, correctval) for name, (val, count) in name2valcount.items(): for _ in range(count): diff --git a/baselines/run.py b/baselines/run.py index 5a48b18..c438d1c 100644 --- a/baselines/run.py +++ b/baselines/run.py @@ -232,7 +232,7 @@ def main(args): env.render() done = done.any() if isinstance(done, np.ndarray) else done if done: - print(f'episode_rew={episode_rew}') + print('episode_rew={}'.format(episode_rew)) episode_rew = 0 obs = env.reset()