This repository was archived by the owner on Sep 10, 2026. It is now read-only.
Repository navigation
Fix tests #130
Merged
Merged
Fix tests #130
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,14 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| import numpy as np | ||
| from ray.rllib.env import PettingZooEnv | ||
| from ray.rllib.env.wrappers.pettingzoo_env import ParallelPettingZooEnv | ||
|
|
||
| if TYPE_CHECKING: | ||
| import numpy.typing as npt | ||
|
|
||
|
|
||
| class PZWrapper(PettingZooEnv): | ||
| """Temporary wrapper for PettingZooEnv. | ||
|
|
@@ -11,12 +18,13 @@ class PZWrapper(PettingZooEnv): | |
| render function, but PettingZoo environments no longer accept an argument. | ||
| """ | ||
|
|
||
| def render(self) -> np._typing.NDArray[np.uint8]: | ||
| # Superclass return type is incorrect: | ||
| # https://github.com/Farama-Foundation/Gymnasium/issues/845#issuecomment-2535827312 | ||
| def render(self) -> npt.NDArray[np.uint8]: # type: ignore[override] | ||
| """RGB image given the current observation. | ||
|
|
||
| Returns: | ||
| np._typing.NDArray[np.uint8]: A numpy uint8 3D array (image) to | ||
| render. | ||
|
Comment on lines
-18
to
-19
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docstrings are nice for explaining the semantics of parameters and return values, but I think we should avoid duplicating type information in them. Of course, before formal Python typing via language syntax, it was more common to put type information in docstrings. |
||
| A numpy uint8 3D array (image) to render. | ||
| """ | ||
| return self.env.render() | ||
|
|
||
|
|
@@ -29,11 +37,12 @@ class ParallelPZWrapper(ParallelPettingZooEnv): | |
| render function, but PettingZoo environments no longer accept an argument. | ||
| """ | ||
|
|
||
| def render(self) -> np._typing.NDArray[np.uint8]: | ||
| # Superclass return type is incorrect: | ||
| # https://github.com/Farama-Foundation/Gymnasium/issues/845#issuecomment-2535827312 | ||
| def render(self) -> npt.NDArray[np.uint8]: # type: ignore[override] | ||
| """RGB image given the current observation. | ||
|
|
||
| Returns: | ||
| np._typing.NDArray[np.uint8]: A numpy uint8 3D array (image) to | ||
| render. | ||
| A numpy uint8 3D array (image) to render. | ||
| """ | ||
| return self.par_env.render() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| from typing import Literal | ||
|
|
||
| from django.db import models | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://numpy.org/doc/stable/reference/typing.html#api and other usage in the code.
For a rigorous library like numpy, there ought to be no need to import private symbols (it's a red flag that "there ought to be a better way"). I appreciate this doesn't hold for other lower-software-quality libraries.