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

MuJoco-v5 environments replace ndarray.flat.copy() with ndarray.flatten() #815

Merged
merged 19 commits into from
Dec 5, 2023

Conversation

Kallinteris-Andreas
Copy link
Collaborator

@Kallinteris-Andreas Kallinteris-Andreas commented Dec 5, 2023

Description

replaces ndarray.flat.copy() with ndarray.flatten() which have the same behavior (https://stackoverflow.com/questions/77579701/does-ndarray-flat-copy-and-ndarray-flatten-do-the-same-thing) and should in theory be slightly faster (though I could not measure an overall speedup)

motivation

MJX & jax does not support array.flat jax-ml/jax#8046, but they support array.flatten()

validation

in the repo: https://github.com/Kallinteris-Andreas/gymnasium-changes-validation/tree/main/flatten
I validated that over 1 mil steps the behavior is identical for all environments
and observed no measurable runtime slowdown

Type of change

  • Effectively no change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@pseudo-rnd-thoughts pseudo-rnd-thoughts merged commit b879469 into Farama-Foundation:main Dec 5, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants