Class VectorizeTransformObservation<TWObs, TObs, TAct>
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
TWObsThe wrapper's batched observation type.
TObsThe env's batched observation type.
TActThe 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
envVectorEnv<TObs, TAct>The vector env.
wrapperTypeThe single-env transform wrapper class (
typeof(FilterObservation<,>)).kwargsobjectThe 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_STEPenv, or what the wrapper's constructor refuses.
Properties
AutoresetMode
The env's autoreset mode (autoreset_mode).
public AutoresetMode AutoresetMode { get; }
Property Value
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
Wrapper
The single-env wrapper whose function is applied (wrapper); owned.
public IEnv Wrapper { get; }
Property Value
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
Observations(TObs)
Each sub-env's observation through the wrapper's function, stacked again.
public override TWObs Observations(TObs observations)
Parameters
observationsTObsThe 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
actionsTActThe actions, passed on.
Returns
- VectorStepResult<TWObs>
The transition with transformed observations.