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

removed inline RandomNumberGenerator implementation #3022

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

balisujohn
Copy link
Contributor

@balisujohn balisujohn commented Aug 12, 2022

Description

Removed inline RandomNumberGenerator implementation and replaced with alias to np.random.Generator.

  • 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

bigint, mod = divmod(bigint, 2**32)
ints.append(mod)
return ints
RandomNumberGenerator = np.random.Generator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RandomNumberGenerator = np.random.Generator
RNG = RandomNumberGenerator = np.random.Generator

I think we shall leave the short name convenience (line 137).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@RedTachyon
Copy link
Contributor

RedTachyon commented Aug 13, 2022

Is there actually anything preventing us from removing the RandomNumberGenerator abstraction completely, and instead just using np.random.Generator, which it is anyways? The extra layer of (trivial, but still) complexity doesn't seem necessary.

@pseudo-rnd-thoughts
Copy link
Contributor

I think for backward compatibility then we should keep it

@RedTachyon
Copy link
Contributor

In that case, let's keep the synonyms (RNG = RandomNumberGenerator = np.random.Generator), but let's not use them in the code itself. So e.g. the return type of np_random should be Tuple[np.random.Generator, Any] instead of Tuple["RandomNumberGenerator", Any]. This won't break any backwards compatibility because it's the same types, but it will keep the codebase a bit more sane.

Copy link
Contributor

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jkterry1 jkterry1 merged commit 7b0b85c into openai:master Aug 22, 2022
Copy link

@pickettgoogle pickettgoogle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing hash_seed from utils/seeding.py breaks gym-retro, which looks for this function there.
The specific line is here:
https://github.com/openai/retro/blob/master/retro/retro_env.py#L214

@pseudo-rnd-thoughts
Copy link
Contributor

You will need to install an older version of gym

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.

None yet

6 participants