Skip to content

Commit

Permalink
making pettingzoo a core dep instead of optional req (#837)
Browse files Browse the repository at this point in the history
close #831
  • Loading branch information
Trinkle23897 authored Mar 26, 2023
1 parent d5d521b commit 7f8fa24
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/extra_sys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: [3.7, 3.8]
python-version: [3.8, 3.9]
steps:
- name: Cancel previous run
uses: styfle/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gputest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: "3.10"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip setuptools wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Cancel previous run
uses: styfle/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_install_requires() -> str:
"numba>=0.51.0",
"h5py>=2.10.0", # to match tensorflow's minimal requirements
"packaging",
"pettingzoo>=1.22",
]


Expand All @@ -47,7 +48,6 @@ def get_extras_require() -> str:
"doc8",
"scipy",
"pillow",
"pettingzoo>=1.22",
"pygame>=2.1.0", # pettingzoo test cases pistonball
"pymunk>=6.2.1", # pettingzoo test cases pistonball
"nni>=2.3,<3.0", # expect breaking changes at next major version
Expand Down
2 changes: 1 addition & 1 deletion tianshou/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tianshou import data, env, exploration, policy, trainer, utils

__version__ = "0.5.0"
__version__ = "0.5.1"

__all__ = [
"env",
Expand Down
6 changes: 1 addition & 5 deletions tianshou/env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
MultiDiscreteToDiscrete,
TruncatedAsTerminated,
)
from tianshou.env.pettingzoo_env import PettingZooEnv
from tianshou.env.venv_wrappers import VectorEnvNormObs, VectorEnvWrapper
from tianshou.env.venvs import (
BaseVectorEnv,
Expand All @@ -14,11 +15,6 @@
SubprocVectorEnv,
)

try:
from tianshou.env.pettingzoo_env import PettingZooEnv
except ImportError:
pass

__all__ = [
"BaseVectorEnv",
"DummyVectorEnv",
Expand Down
4 changes: 2 additions & 2 deletions tianshou/env/gym_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, env: gym.Env, action_per_dim: Union[int, List[int]]) -> None:
dtype=object
)

def action(self, act: np.ndarray) -> np.ndarray: # type: ignore
def action(self, act: np.ndarray) -> np.ndarray:
# modify act
assert len(act.shape) <= 2, f"Unknown action format with shape {act.shape}."
if len(act.shape) == 1:
Expand All @@ -50,7 +50,7 @@ def __init__(self, env: gym.Env) -> None:
self.bases[i] = self.bases[i - 1] * nvec[-i]
self.action_space = gym.spaces.Discrete(np.prod(nvec))

def action(self, act: np.ndarray) -> np.ndarray: # type: ignore
def action(self, act: np.ndarray) -> np.ndarray:
converted_act = []
for b in np.flip(self.bases):
converted_act.append(act // b)
Expand Down
5 changes: 1 addition & 4 deletions tianshou/env/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import gymnasium
import numpy as np

try:
from tianshou.env.pettingzoo_env import PettingZooEnv
except ImportError:
PettingZooEnv = None # type: ignore
from tianshou.env.pettingzoo_env import PettingZooEnv

if TYPE_CHECKING:
import gym
Expand Down
6 changes: 1 addition & 5 deletions tianshou/env/venvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
import packaging

from tianshou.env.pettingzoo_env import PettingZooEnv
from tianshou.env.utils import ENV_TYPE, gym_new_venv_step_type
from tianshou.env.worker import (
DummyEnvWorker,
Expand All @@ -13,11 +14,6 @@
SubprocEnvWorker,
)

try:
from tianshou.env.pettingzoo_env import PettingZooEnv
except ImportError:
PettingZooEnv = None # type: ignore

try:
import gym as old_gym

Expand Down

0 comments on commit 7f8fa24

Please sign in to comment.