Table of Contents

Class FilterObservation<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

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

TObs

The observation type: Info for a Dict env, object?[] for a Tuple env, or object.

TAct

The 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

env Env<TObs, TAct>

The env to wrap.

options FilterObservationOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is 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

env Env<TObs, TAct>

The env; its observation space must be a Dict or a Tuple.

filterKeys object

The keys to keep, as a Python sequence: an object?[] (a tuple) or a list of strings for a Dict, of integers for a Tuple (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 filterKeys is no sequence, or its keys are not strings for a Dict or not integers for a Tuple; also when env is 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 Dict nor a Tuple.

Properties

FilterKeys

The keys kept, as given (filter_keys).

public object FilterKeys { get; }

Property Value

object