Table of Contents

Class VectorizeTransformObservation<TWObs, TObs, TAct>

Namespace
Gym.Wrappers.Vector
Assembly
Gym.dll

Vectorizes a single-env observation transform (Gymnasium's VectorizeTransformObservation): the wrapper class is built over a stand-in env of the single space, and its function is applied to each sub-env's observation, the results stacked into the batch.

public class VectorizeTransformObservation<TWObs, TObs, TAct> : VectorObservationWrapper<TWObs, TObs, TAct>, IVectorEnv, IDisposable

Type Parameters

TWObs

The wrapper's batched observation type.

TObs

The env's batched observation type.

TAct

The batched action type, passed through.

Inheritance
VectorEnv<TWObs, TAct>
VectorWrapper<TWObs, TAct, TObs, TAct>
VectorObservationWrapper<TWObs, TObs, TAct>
VectorizeTransformObservation<TWObs, TObs, TAct>
Implements
Derived
Inherited Members
Extension Methods

Remarks

When the wrapper's batched space equals the env's (same_out), the results are written into the env's own batch, in place, as in Gymnasium; otherwise into the wrapper's buffer, and a deep copy is returned. A missing autoreset_mode warns and means NEXT_STEP.

Reference: gymnasium/wrappers/vector/vectorize_observation.py.

Constructors

VectorizeTransformObservation(VectorEnv<TObs, TAct>, Type, object?)

Wraps env, building wrapper over its single observation space.

public VectorizeTransformObservation(VectorEnv<TObs, TAct> env, Type wrapper, object? kwargs = null)

Parameters

env VectorEnv<TObs, TAct>

The vector env.

wrapper Type

The single-env transform wrapper class (typeof(FilterObservation<,>)).

kwargs object

The wrapper's other arguments by Python name (a dictionary or an anonymous object), or null.

Exceptions

TypeError

Thrown when the class cannot be vectorized or built, the mode is not an AutoresetMode, or a space does not hold TWObs.

ValueError

Thrown for a SAME_STEP env, or what the wrapper's constructor refuses.

Properties

AutoresetMode

The env's autoreset mode (autoreset_mode).

public AutoresetMode AutoresetMode { get; }

Property Value

AutoresetMode

SameOut

Whether the wrapper's batched space equals the env's, so results go into the env's batch (same_out).

public bool SameOut { get; }

Property Value

bool

Wrapper

The single-env wrapper whose function is applied (wrapper); owned.

public IEnv Wrapper { get; }

Property Value

IEnv

Methods

Dispose(bool)

Releases the buffer and the single-env wrapper, then disposes as every vector wrapper does.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true from Dispose().

Observations(TObs)

Each sub-env's observation through the wrapper's function, stacked again.

public override TWObs Observations(TObs observations)

Parameters

observations TObs

The env's batched observations.

Returns

TWObs

The env's batch filled in place (SameOut), or a deep copy of the wrapper's buffer.

Step(TAct)

Steps the env and transforms the observations; with SAME_STEP, each final_obs too.

public override VectorStepResult<TWObs> Step(TAct actions)

Parameters

actions TAct

The actions, passed on.

Returns

VectorStepResult<TWObs>

The transition with transformed observations.