FlattenObservation
- class fluidgym.wrappers.flatten_obs.FlattenObservation(env: FluidEnvLike)[source]
Bases:
FluidWrapperA wrapper that flattens the observation space.
It flattens each observation tensor in the observation dictionary.
- Parameters:
env (FluidEnvLike) – The environment to wrap.
- property observation_space: Box
The observation space of the environment.
- reset(seed: int | None = None, randomize: bool | None = None) tuple[Tensor, dict[str, Tensor]][source]
Resets the environment to an initial internal state, returning an initial observation and info.
- Parameters:
seed (int | None) – The seed to use for random number generation. If None, the current seed is used.
randomize (bool | None) – Whether to randomize the initial state. If None, the default behavior is used.
- Returns:
A tuple containing the initial observation and an info dictionary.
- Return type:
tuple[torch.Tensor, dict[str, torch.Tensor]]
- step(action: Tensor) tuple[Tensor, Tensor, bool, bool, dict[str, Tensor]][source]
Run one timestep of the environment’s dynamics using the agent actions.
When the end of an episode is reached (
terminated or truncated), it is necessary to callreset()to reset this environment’s state for the next episode.- Parameters:
action (torch.Tensor) – The action to take.
- Returns:
A tuple containing the flattened observation, reward, terminated flag, truncated flag, and info dictionary.
- Return type:
tuple[torch.Tensor, torch.Tensor, bool, bool, dict[str, torch.Tensor]]