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

[Proposal] Allow frame stack for stacks of size 1 #1085

Open
1 task done
albertwilcox opened this issue Jun 13, 2024 · 1 comment
Open
1 task done

[Proposal] Allow frame stack for stacks of size 1 #1085

albertwilcox opened this issue Jun 13, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@albertwilcox
Copy link

Proposal

Hi,

I propose that the framework is updated to allow frame stacks of size 1. This could be helpful for pipelines which might use frame stacks in some settings and omit them in others. By allowing frame stacks of size 1 the frame stack wrapper can be left in the code and automatically add the extra dimension for frame stacking.

To implement this, simply remove these lines:

if not 1 < stack_size:
raise ValueError(
f"The stack_size needs to be greater than one, actual value: {stack_size}"
)

Previous versions of the gym wrapper supported this: https://github.com/openai/gym/blob/master/gym/wrappers/frame_stack.py

Motivation

As described above, this will enable cleaner code for several applications without causing any issues to existing ones. Also, this is consistent with previous versions of the gym frame stack wrapper.

Pitch

Just remove these lines or maybe assert stack-size > 0 instead

https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/wrappers/stateful_observation.py#L377-L380

Alternatives

No response

Additional context

No response

Checklist

  • I have checked that there is no similar issue in the repo
@albertwilcox albertwilcox added the enhancement New feature or request label Jun 13, 2024
@pseudo-rnd-thoughts
Copy link
Member

Hey, thanks for the suggestion, I originally included the >1 as I thought you wouldn't need ==1 but your motivation is good counter-argument.
If the tests work then I see no reason why we can't relax the assumption.
Could you make a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants