rldurham.RLDurhamEnv

class rldurham.RLDurhamEnv(env)[source]

Bases: Wrapper

Light-weight environment wrapper to enable logging.

Public Data Attributes:

metadata

Returns the Env metadata.

render_mode

Returns the Env render_mode.

spec

Returns the Env spec attribute with the WrapperSpec if the wrapper inherits from EzPickle.

action_space

Return the Env action_space unless overwritten then the wrapper action_space is used.

observation_space

Return the Env observation_space unless overwritten then the wrapper observation_space is used.

Inherited from Wrapper

np_random_seed

Returns the base environment's np_random_seed.

unwrapped

Returns the base environment of the wrapper.

spec

Returns the Env spec attribute with the WrapperSpec if the wrapper inherits from EzPickle.

action_space

Return the Env action_space unless overwritten then the wrapper action_space is used.

observation_space

Return the Env observation_space unless overwritten then the wrapper observation_space is used.

metadata

Returns the Env metadata.

render_mode

Returns the Env render_mode.

np_random

Returns the Env np_random attribute.

Inherited from Env

metadata

render_mode

spec

unwrapped

Returns the base non-wrapped environment.

np_random_seed

Returns the environment's internal _np_random_seed that if not set will first initialise with a random int as seed.

np_random

Returns the environment's internal _np_random that if not set will initialise with a random seed.

action_space

observation_space

Public Methods:

__init__(env)

Wraps an environment to allow a modular transformation of the step() and reset() methods.

step(action)

Uses the step() of the env that can be overwritten to change the returned data.

__getattr__(item)

Inherited from Wrapper

__init__(env)

Wraps an environment to allow a modular transformation of the step() and reset() methods.

step(action)

Uses the step() of the env that can be overwritten to change the returned data.

reset(*[, seed, options])

Uses the reset() of the env that can be overwritten to change the returned data.

render()

Uses the render() of the env that can be overwritten to change the returned data.

close()

Closes the wrapper and env.

wrapper_spec(**kwargs)

Generates a WrapperSpec for the wrappers.

has_wrapper_attr(name)

Checks if the given attribute is within the wrapper or its environment.

get_wrapper_attr(name)

Gets an attribute from the wrapper and lower environments if name doesn't exist in this object.

set_wrapper_attr(name, value)

Sets an attribute on this wrapper or lower environment if name is already defined.

__str__()

Returns the wrapper name and the env representation string.

__repr__()

Returns the string representation of the wrapper.

class_name()

Returns the class name of the wrapper.

Inherited from Env

step(action)

Run one timestep of the environment's dynamics using the agent actions.

reset(*[, seed, options])

Resets the environment to an initial internal state, returning an initial observation and info.

render()

Compute the render frames as specified by render_mode during the initialization of the environment.

close()

After the user has finished using the environment, close contains the code necessary to "clean up" the environment.

__str__()

Returns a string of the environment with spec id's if :attr:`spec.

__enter__()

Support with-statement for the environment.

__exit__(*args)

Support with-statement for the environment and closes the environment.

has_wrapper_attr(name)

Checks if the attribute name exists in the environment.

get_wrapper_attr(name)

Gets the attribute name from the environment.

set_wrapper_attr(name, value)

Sets the attribute name on the environment with value.

Inherited from Generic

__class_getitem__

Parameterizes a generic class.

__init_subclass__

Function to initialize subclasses.

Private Data Attributes:

_action_space

_observation_space

_metadata

_cached_spec

_np_random

This code will never be run due to __getattr__ being called prior this.

_np_random_seed

Inherited from Wrapper

_np_random

This code will never be run due to __getattr__ being called prior this.

Inherited from Env

_np_random

_np_random_seed


__annotations__ = {}
classmethod __class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

__dict__ = mappingproxy({'__module__': 'rldurham', '__doc__': '\n    Light-weight environment wrapper to enable logging.\n    ', '__init__': <function RLDurhamEnv.__init__>, 'step': <function RLDurhamEnv.step>, '__parameters__': (), '__getattr__': <function transparent_wrapper.<locals>.__getattr__>, '__annotations__': {'_action_space': 'spaces.Space[WrapperActType] | None', '_observation_space': 'spaces.Space[WrapperObsType] | None', '_metadata': 'dict[str, Any] | None', '_cached_spec': 'EnvSpec | None', 'metadata': 'dict[str, Any]', 'render_mode': 'str | None', 'spec': 'EnvSpec | None', 'action_space': 'spaces.Space[ActType]', 'observation_space': 'spaces.Space[ObsType]', '_np_random': 'np.random.Generator | None', '_np_random_seed': 'int | None'}})
__enter__()

Support with-statement for the environment.

__exit__(*args)

Support with-statement for the environment and closes the environment.

__getattr__(item)
__init__(env)[source]

Wraps an environment to allow a modular transformation of the step() and reset() methods.

Args:

env: The environment to wrap

classmethod __init_subclass__()

Function to initialize subclasses.

__module__ = 'rldurham'
__orig_bases__ = (gymnasium.core.Env[~WrapperObsType, ~WrapperActType], typing.Generic[~WrapperObsType, ~WrapperActType, ~ObsType, ~ActType])
__parameters__ = ()
__repr__()

Returns the string representation of the wrapper.

__str__()

Returns the wrapper name and the env representation string.

__weakref__

list of weak references to the object

property _np_random

This code will never be run due to __getattr__ being called prior this.

It seems that @property overwrites the variable (_np_random) meaning that __getattr__ gets called with the missing variable.

_np_random_seed: int | None = None
property action_space: Space[ActType] | Space[WrapperActType]

Return the Env action_space unless overwritten then the wrapper action_space is used.

classmethod class_name()

Returns the class name of the wrapper.

Return type:

str

close()

Closes the wrapper and env.

get_wrapper_attr(name)

Gets an attribute from the wrapper and lower environments if name doesn’t exist in this object.

Return type:

Any

Args:

name: The variable name to get

Returns:

The variable with name in wrapper or lower environments

has_wrapper_attr(name)

Checks if the given attribute is within the wrapper or its environment.

Return type:

bool

property metadata: dict[str, Any]

Returns the Env metadata.

property np_random: Generator

Returns the Env np_random attribute.

property np_random_seed: int | None

Returns the base environment’s np_random_seed.

property observation_space: Space[ObsType] | Space[WrapperObsType]

Return the Env observation_space unless overwritten then the wrapper observation_space is used.

render()

Uses the render() of the env that can be overwritten to change the returned data.

Return type:

Union[TypeVar(RenderFrame), list[TypeVar(RenderFrame)], None]

property render_mode: str | None

Returns the Env render_mode.

reset(*, seed=None, options=None)

Uses the reset() of the env that can be overwritten to change the returned data.

Return type:

tuple[TypeVar(WrapperObsType), dict[str, Any]]

set_wrapper_attr(name, value)

Sets an attribute on this wrapper or lower environment if name is already defined.

Args:

name: The variable name value: The new variable value

property spec: EnvSpec | None

Returns the Env spec attribute with the WrapperSpec if the wrapper inherits from EzPickle.

step(action)[source]

Uses the step() of the env that can be overwritten to change the returned data.

property unwrapped: Env[ObsType, ActType]

Returns the base environment of the wrapper.

This will be the bare gymnasium.Env environment, underneath all layers of wrappers.

classmethod wrapper_spec(**kwargs)

Generates a WrapperSpec for the wrappers.

Return type:

WrapperSpec