Skip to content

Commit 7aaa45a

Browse files
committed
fix bug related to hasattr
1 parent f67d278 commit 7aaa45a

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

accel/agents/sac.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def _eval_one_episode(self, env, frames, record=False,
251251
self._add_obs_to_frame(img, frames)
252252

253253
total_reward += reward
254-
if hasattr(info, 'success'):
254+
if 'success' in info.keys():
255255
success |= bool(info['success'])
256256

257257
if not hasattr(env, 'was_real_done') or env.was_real_done:

examples/atari_dqn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ def main(cfg):
170170
step += 1
171171

172172
timeout_label = 'TimeLimit.truncated'
173-
timeout = hasattr(
174-
info, timeout_label) and info[timeout_label]
173+
timeout = timeout_label in info.keys() and info[timeout_label]
175174
next_valid = 1. if timeout else float(not done)
176175
agent.update(obs, action, next_obs, reward, next_valid)
177176

0 commit comments

Comments
 (0)