Table of Contents

Class ReshapeObservation<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Reshapes every array observation, as Gymnasium's ReshapeObservation does; the space's bounds are reshaped with it.

public class ReshapeObservation<TObs, TAct> : TransformObservation<NDArray, TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs

Type Parameters

TObs

The env's observation type: arrays (NDArray, or object holding them).

TAct

The action type, passed through.

Inheritance
Env<NDArray, TAct>
Wrapper<NDArray, TAct, TObs, TAct>
ReshapeObservation<TObs, TAct>
Implements
Inherited Members
Extension Methods

Remarks

Each observation is np.reshape(obs, shape), a view of the env's observation where NumPy gives one, as in Python: disposing it does not free the env's array.

Reference: gymnasium/wrappers/transform_observation.py.

Constructors

ReshapeObservation(Env<TObs, TAct>, ReshapeObservationOptions)

Builds the instance from its options record: the properties set, the constructor's defaults for the rest.

public ReshapeObservation(Env<TObs, TAct> env, ReshapeObservationOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options ReshapeObservationOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

TypeError

Thrown when a required argument is unset, with Python's missing-argument message.

ReshapeObservation(Env<TObs, TAct>, long[])

Wraps env.

public ReshapeObservation(Env<TObs, TAct> env, long[] shape)

Parameters

env Env<TObs, TAct>

The env; its observation space must be a Box.

shape long[]

The new shape; its product must equal the space's (Gymnasium's check, which a -1 element therefore never passes).

Exceptions

TypeError

Thrown when the space is no Box (Gymnasium's message), or env is null.

ArgumentNullException

Thrown when shape is null.

ValueError

Thrown when the products differ, or an element is neither positive nor -1, with Gymnasium's messages.

Properties

Shape

The new shape (shape).

public long[] Shape { get; }

Property Value

long[]