Skip to content

Commit 94384bb

Browse files
Re-add functional api to experimental (#1145)
1 parent 88335e7 commit 94384bb

File tree

10 files changed

+22
-14
lines changed

10 files changed

+22
-14
lines changed

Diff for: gymnasium/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
VectorizeMode,
2121
register_envs,
2222
)
23-
from gymnasium import spaces, utils, vector, wrappers, error, logger, functional
23+
from gymnasium import spaces, utils, vector, wrappers, error, logger, experimental
2424

2525
# Initializing pygame initializes audio connections through SDL. SDL uses alsa by default on all Linux systems
2626
# SDL connecting to alsa frequently create these giant lists of warnings every time you import an environment using
@@ -64,7 +64,7 @@
6464
"wrappers",
6565
"error",
6666
"logger",
67-
"functional",
67+
"experimental",
6868
]
6969
__version__ = "1.0.0"
7070

Diff for: gymnasium/envs/functional_jax_env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import gymnasium as gym
1212
from gymnasium.envs.registration import EnvSpec
13-
from gymnasium.functional import ActType, FuncEnv, StateType
13+
from gymnasium.experimental.functional import ActType, FuncEnv, StateType
1414
from gymnasium.utils import seeding
1515
from gymnasium.vector.utils import batch_space
1616

Diff for: gymnasium/envs/phys2d/cartpole.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import gymnasium as gym
1414
from gymnasium.envs.functional_jax_env import FunctionalJaxEnv, FunctionalJaxVectorEnv
1515
from gymnasium.error import DependencyNotInstalled
16-
from gymnasium.functional import ActType, FuncEnv, StateType
16+
from gymnasium.experimental.functional import ActType, FuncEnv, StateType
1717
from gymnasium.utils import EzPickle
1818

1919

Diff for: gymnasium/envs/phys2d/pendulum.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import gymnasium as gym
1515
from gymnasium.envs.functional_jax_env import FunctionalJaxEnv, FunctionalJaxVectorEnv
1616
from gymnasium.error import DependencyNotInstalled
17-
from gymnasium.functional import ActType, FuncEnv, StateType
17+
from gymnasium.experimental.functional import ActType, FuncEnv, StateType
1818
from gymnasium.utils import EzPickle
1919

2020

Diff for: gymnasium/envs/tabular/blackjack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from gymnasium import spaces
1515
from gymnasium.envs.functional_jax_env import FunctionalJaxEnv
1616
from gymnasium.error import DependencyNotInstalled
17-
from gymnasium.functional import ActType, FuncEnv, StateType
17+
from gymnasium.experimental.functional import ActType, FuncEnv, StateType
1818
from gymnasium.utils import EzPickle, seeding
1919
from gymnasium.wrappers import HumanRendering
2020

Diff for: gymnasium/envs/tabular/cliffwalking.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from gymnasium import spaces
1414
from gymnasium.envs.functional_jax_env import FunctionalJaxEnv
1515
from gymnasium.error import DependencyNotInstalled
16-
from gymnasium.functional import ActType, FuncEnv, StateType
16+
from gymnasium.experimental.functional import ActType, FuncEnv, StateType
1717
from gymnasium.utils import EzPickle
1818
from gymnasium.wrappers import HumanRendering
1919

Diff for: gymnasium/experimental/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Experimental module."""
File renamed without changes.

Diff for: tests/envs/functional/test_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44

5-
from gymnasium.functional import FuncEnv
5+
from gymnasium.experimental.functional import FuncEnv
66

77

88
class BasicTestEnv(FuncEnv):

Diff for: tests/functional/test_functional.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88

9-
from gymnasium.functional import FuncEnv
9+
from gymnasium.experimental.functional import FuncEnv
1010

1111

1212
class GenericTestFuncEnv(FuncEnv):
@@ -16,25 +16,32 @@ def __init__(self, options: dict[str, Any] | None = None):
1616
"""Constructor that allows generic options to be set on the environment."""
1717
super().__init__(options)
1818

19-
def initial(self, rng: Any) -> np.ndarray:
19+
def initial(self, rng: Any, params=None) -> np.ndarray:
2020
"""Testing initial function."""
2121
return np.array([0, 0], dtype=np.float32)
2222

23-
def observation(self, state: np.ndarray, rng: Any) -> np.ndarray:
23+
def observation(self, state: np.ndarray, rng: Any, params=None) -> np.ndarray:
2424
"""Testing observation function."""
2525
return state
2626

27-
def transition(self, state: np.ndarray, action: int, rng: None) -> np.ndarray:
27+
def transition(
28+
self, state: np.ndarray, action: int, rng: None, params=None
29+
) -> np.ndarray:
2830
"""Testing transition function."""
2931
return state + np.array([0, action], dtype=np.float32)
3032

3133
def reward(
32-
self, state: np.ndarray, action: int, next_state: np.ndarray, rng: Any
34+
self,
35+
state: np.ndarray,
36+
action: int,
37+
next_state: np.ndarray,
38+
rng: Any,
39+
params=None,
3340
) -> float:
3441
"""Testing reward function."""
3542
return 1.0 if next_state[1] > 0 else 0.0
3643

37-
def terminal(self, state: np.ndarray, rng: Any) -> bool:
44+
def terminal(self, state: np.ndarray, rng: Any, params=None) -> bool:
3845
"""Testing terminal function."""
3946
return state[1] > 0
4047

0 commit comments

Comments
 (0)