Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop caching the result of numpy.concatenate in LazyFrames #332

Merged
merged 1 commit into from
Oct 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions examples/ale/atari_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,26 +230,13 @@ class LazyFrames(object):
def __init__(self, frames, stack_axis=2):
self.stack_axis = stack_axis
self._frames = frames
self._out = None

def _force(self):
if self._out is None:
self._out = np.concatenate(self._frames, axis=self.stack_axis)
self._frames = None
return self._out

def __array__(self, dtype=None):
out = self._force()
out = np.concatenate(self._frames, axis=self.stack_axis)
if dtype is not None:
out = out.astype(dtype)
return out

def __len__(self):
return len(self._force())

def __getitem__(self, i):
return self._force()[i]


def make_atari(env_id):
env = gym.make(env_id)
Expand Down