parent
d5d521b329
commit
7f8fa241dd
2
.github/workflows/extra_sys.yml
vendored
2
.github/workflows/extra_sys.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest]
|
os: [macos-latest, windows-latest]
|
||||||
python-version: [3.7, 3.8]
|
python-version: [3.8, 3.9]
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel previous run
|
- name: Cancel previous run
|
||||||
uses: styfle/cancel-workflow-action@0.11.0
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
4
.github/workflows/gputest.yml
vendored
4
.github/workflows/gputest.yml
vendored
@ -12,10 +12,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
access_token: ${{ github.token }}
|
access_token: ${{ github.token }}
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python 3.8
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: "3.10"
|
||||||
- name: Upgrade pip
|
- name: Upgrade pip
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip setuptools wheel
|
python -m pip install --upgrade pip setuptools wheel
|
||||||
|
2
.github/workflows/pytest.yml
vendored
2
.github/workflows/pytest.yml
vendored
@ -8,7 +8,7 @@ jobs:
|
|||||||
if: "!contains(github.event.head_commit.message, 'ci skip')"
|
if: "!contains(github.event.head_commit.message, 'ci skip')"
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.7, 3.8, 3.9]
|
python-version: ["3.8", "3.9", "3.10"]
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel previous run
|
- name: Cancel previous run
|
||||||
uses: styfle/cancel-workflow-action@0.11.0
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
2
setup.py
2
setup.py
@ -23,6 +23,7 @@ def get_install_requires() -> str:
|
|||||||
"numba>=0.51.0",
|
"numba>=0.51.0",
|
||||||
"h5py>=2.10.0", # to match tensorflow's minimal requirements
|
"h5py>=2.10.0", # to match tensorflow's minimal requirements
|
||||||
"packaging",
|
"packaging",
|
||||||
|
"pettingzoo>=1.22",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +48,6 @@ def get_extras_require() -> str:
|
|||||||
"doc8",
|
"doc8",
|
||||||
"scipy",
|
"scipy",
|
||||||
"pillow",
|
"pillow",
|
||||||
"pettingzoo>=1.22",
|
|
||||||
"pygame>=2.1.0", # pettingzoo test cases pistonball
|
"pygame>=2.1.0", # pettingzoo test cases pistonball
|
||||||
"pymunk>=6.2.1", # pettingzoo test cases pistonball
|
"pymunk>=6.2.1", # pettingzoo test cases pistonball
|
||||||
"nni>=2.3,<3.0", # expect breaking changes at next major version
|
"nni>=2.3,<3.0", # expect breaking changes at next major version
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from tianshou import data, env, exploration, policy, trainer, utils
|
from tianshou import data, env, exploration, policy, trainer, utils
|
||||||
|
|
||||||
__version__ = "0.5.0"
|
__version__ = "0.5.1"
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"env",
|
"env",
|
||||||
|
6
tianshou/env/__init__.py
vendored
6
tianshou/env/__init__.py
vendored
@ -5,6 +5,7 @@ from tianshou.env.gym_wrappers import (
|
|||||||
MultiDiscreteToDiscrete,
|
MultiDiscreteToDiscrete,
|
||||||
TruncatedAsTerminated,
|
TruncatedAsTerminated,
|
||||||
)
|
)
|
||||||
|
from tianshou.env.pettingzoo_env import PettingZooEnv
|
||||||
from tianshou.env.venv_wrappers import VectorEnvNormObs, VectorEnvWrapper
|
from tianshou.env.venv_wrappers import VectorEnvNormObs, VectorEnvWrapper
|
||||||
from tianshou.env.venvs import (
|
from tianshou.env.venvs import (
|
||||||
BaseVectorEnv,
|
BaseVectorEnv,
|
||||||
@ -14,11 +15,6 @@ from tianshou.env.venvs import (
|
|||||||
SubprocVectorEnv,
|
SubprocVectorEnv,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
from tianshou.env.pettingzoo_env import PettingZooEnv
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"BaseVectorEnv",
|
"BaseVectorEnv",
|
||||||
"DummyVectorEnv",
|
"DummyVectorEnv",
|
||||||
|
4
tianshou/env/gym_wrappers.py
vendored
4
tianshou/env/gym_wrappers.py
vendored
@ -26,7 +26,7 @@ class ContinuousToDiscrete(gym.ActionWrapper):
|
|||||||
dtype=object
|
dtype=object
|
||||||
)
|
)
|
||||||
|
|
||||||
def action(self, act: np.ndarray) -> np.ndarray: # type: ignore
|
def action(self, act: np.ndarray) -> np.ndarray:
|
||||||
# modify act
|
# modify act
|
||||||
assert len(act.shape) <= 2, f"Unknown action format with shape {act.shape}."
|
assert len(act.shape) <= 2, f"Unknown action format with shape {act.shape}."
|
||||||
if len(act.shape) == 1:
|
if len(act.shape) == 1:
|
||||||
@ -50,7 +50,7 @@ class MultiDiscreteToDiscrete(gym.ActionWrapper):
|
|||||||
self.bases[i] = self.bases[i - 1] * nvec[-i]
|
self.bases[i] = self.bases[i - 1] * nvec[-i]
|
||||||
self.action_space = gym.spaces.Discrete(np.prod(nvec))
|
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 = []
|
converted_act = []
|
||||||
for b in np.flip(self.bases):
|
for b in np.flip(self.bases):
|
||||||
converted_act.append(act // b)
|
converted_act.append(act // b)
|
||||||
|
3
tianshou/env/utils.py
vendored
3
tianshou/env/utils.py
vendored
@ -4,10 +4,7 @@ import cloudpickle
|
|||||||
import gymnasium
|
import gymnasium
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
try:
|
|
||||||
from tianshou.env.pettingzoo_env import PettingZooEnv
|
from tianshou.env.pettingzoo_env import PettingZooEnv
|
||||||
except ImportError:
|
|
||||||
PettingZooEnv = None # type: ignore
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import gym
|
import gym
|
||||||
|
6
tianshou/env/venvs.py
vendored
6
tianshou/env/venvs.py
vendored
@ -5,6 +5,7 @@ import gymnasium as gym
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import packaging
|
import packaging
|
||||||
|
|
||||||
|
from tianshou.env.pettingzoo_env import PettingZooEnv
|
||||||
from tianshou.env.utils import ENV_TYPE, gym_new_venv_step_type
|
from tianshou.env.utils import ENV_TYPE, gym_new_venv_step_type
|
||||||
from tianshou.env.worker import (
|
from tianshou.env.worker import (
|
||||||
DummyEnvWorker,
|
DummyEnvWorker,
|
||||||
@ -13,11 +14,6 @@ from tianshou.env.worker import (
|
|||||||
SubprocEnvWorker,
|
SubprocEnvWorker,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
from tianshou.env.pettingzoo_env import PettingZooEnv
|
|
||||||
except ImportError:
|
|
||||||
PettingZooEnv = None # type: ignore
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import gym as old_gym
|
import gym as old_gym
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user