Class FilterObservation<TObs, TAct>
Keeps only some keys of a Dict observation, or some indices of a Tuple one, as Gymnasium's
FilterObservation does; the space is filtered the same way.
public class FilterObservation<TObs, TAct> : TransformObservation<TObs, TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs
Type Parameters
TObsThe observation type: Info for a
Dictenv, object?[] for aTupleenv, or object.TActThe action type, passed through.
- Inheritance
-
Env<TObs, TAct>Wrapper<TObs, TAct, TObs, TAct>ObservationWrapper<TObs, TObs, TAct>TransformObservation<TObs, TObs, TAct>FilterObservation<TObs, TAct>
- Implements
- Inherited Members
- Extension Methods
Remarks
The filtered observation is a new dict or tuple holding the env's values themselves, not copies. The filtered space holds copies of the env's subspaces (Python shares the subspace objects), so the wrapper can own and dispose it; sampling it does not advance the env's subspaces' generators.
Reference: gymnasium/wrappers/transform_observation.py.
Constructors
FilterObservation(Env<TObs, TAct>, FilterObservationOptions)
Builds the instance from its options record: the properties set, the constructor's defaults for the rest.
public FilterObservation(Env<TObs, TAct> env, FilterObservationOptions options)
Parameters
envEnv<TObs, TAct>The env to wrap.
optionsFilterObservationOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.- TypeError
Thrown when a required argument is unset, with Python's missing-argument message.
FilterObservation(Env<TObs, TAct>, object)
Wraps env.
public FilterObservation(Env<TObs, TAct> env, object filterKeys)
Parameters
envEnv<TObs, TAct>The env; its observation space must be a
Dictor aTuple.filterKeysobjectThe keys to keep, as a Python sequence: an object?[] (a tuple) or a list of strings for a
Dict, of integers for aTuple(negative indices count from the end). A string is a sequence of one-character keys, as in Python.
Exceptions
- TypeError
Thrown, with Gymnasium's messages, when
filterKeysis no sequence, or its keys are not strings for aDictor not integers for aTuple; also whenenvis null.- ValueError
Thrown, with Gymnasium's messages, for keys the space lacks, duplicate tuple indices, a filter that keeps nothing, or a space that is neither a
Dictnor aTuple.
Properties
FilterKeys
The keys kept, as given (filter_keys).
public object FilterKeys { get; }